fix(Kafka Node): Use lazy imports to fix build metadata generation#25794
fix(Kafka Node): Use lazy imports to fix build metadata generation#25794caloganathan wants to merge 1 commit inton8n-io:masterfrom
Conversation
The newly added Kafka and KafkaTrigger nodes were failing during the build process when the metadata generation script tried to load them. The issue was that kafkajs and @kafkajs/confluent-schema-registry were being imported at the module level, which caused failures when loaded in the VM context during metadata generation. This fix makes all kafkajs-related imports lazy by using dynamic imports (await import()) only when the node actually executes, allowing the metadata generation to complete successfully. Changes: - Kafka.node.ts: Lazy load kafkajs and SchemaRegistry - KafkaTrigger.node.ts: Lazy load kafkajs - utils.ts: Lazy load logLevel and SchemaRegistry Fixes Render deployment build error. https://claude.ai/code/session_01W77KEXx3SkQzU8gvfNVpUj
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acb02b725d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const ssl = credentials.ssl as boolean; | ||
|
|
||
| const config: KafkaConfig = { | ||
| const config: any = { |
There was a problem hiding this comment.
Restore KafkaConfig typing instead of
any
This change downgrades config from KafkaConfig to any, which removes compile-time validation for Kafka client and SASL settings and allows malformed options to reach runtime failures in credential tests and execution paths. The same untyped pattern is repeated in this commit across the Kafka node files, and it conflicts with the package rule in packages/nodes-base/AGENTS.md (“Never use any type”); using type-only references (for example import('kafkajs').KafkaConfig) would keep lazy loading without losing safety.
Useful? React with 👍 / 👎.
|
Hey @caloganathan, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: Regarding new nodes: If your node integrates with an AI service that you own or represent, please email nodes@n8n.io and we will be happy to discuss the best approach. About review timelines: Thank you again for contributing to n8n. |
|
Hey @caloganathan The Kafka nodes are not new and our builds seem to be working, can you share what error you were seeing and how you were building? |
The newly added Kafka and KafkaTrigger nodes were failing during the build process when the metadata generation script tried to load them. The issue was that kafkajs and @kafkajs/confluent-schema-registry were being imported at the module level, which caused failures when loaded in the VM context during metadata generation.
This fix makes all kafkajs-related imports lazy by using dynamic imports (await import()) only when the node actually executes, allowing the metadata generation to complete successfully.
Changes:
Fixes Render deployment build error.
https://claude.ai/code/session_01W77KEXx3SkQzU8gvfNVpUj
Summary
Related Linear tickets, Github issues, and Community forum posts
Review / Merge checklist
release/backport(if the PR is an urgent fix that needs to be backported)