From ce154150e89de9f31d239e6f4c222edc2f608d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 18 Aug 2026 14:19:53 +0000 Subject: [PATCH] build: Install Kafka binding on fresh clone (#36502) --- .github/scripts/docker/kafka-native-smoke-check.mjs | 4 +++- .github/workflows/test-unit-reusable.yml | 7 +++++++ package.json | 4 +++- patches/@confluentinc__kafka-javascript@1.9.1.patch | 13 +++++++++++++ pnpm-lock.yaml | 7 +++++-- scripts/build-n8n.mjs | 7 ++++++- 6 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 patches/@confluentinc__kafka-javascript@1.9.1.patch diff --git a/.github/scripts/docker/kafka-native-smoke-check.mjs b/.github/scripts/docker/kafka-native-smoke-check.mjs index c711143a153..4ca97b4e459 100644 --- a/.github/scripts/docker/kafka-native-smoke-check.mjs +++ b/.github/scripts/docker/kafka-native-smoke-check.mjs @@ -14,7 +14,9 @@ const REQUIRED_FEATURES = ['ssl', 'sasl_scram']; const COMPRESSION_CODECS = ['gzip', 'snappy', 'lz4', 'zstd']; const n8nInstallDir = process.env.N8N_INSTALL_DIR || '/usr/local/lib/node_modules/n8n'; -const nodesBasePackageJson = path.join(n8nInstallDir, 'node_modules/n8n-nodes-base/package.json'); +const nodesBasePackageJson = + process.env.NODES_BASE_PACKAGE_JSON || + path.join(n8nInstallDir, 'node_modules/n8n-nodes-base/package.json'); // n8n-nodes-base is a pnpm symlink; resolve it so require() walks up from its real // location in the pnpm virtual store, where its dependencies actually live. const require = createRequire(realpathSync(nodesBasePackageJson)); diff --git a/.github/workflows/test-unit-reusable.yml b/.github/workflows/test-unit-reusable.yml index 7adbae732bd..4c05b2be742 100644 --- a/.github/workflows/test-unit-reusable.yml +++ b/.github/workflows/test-unit-reusable.yml @@ -54,6 +54,13 @@ jobs: with: node-version: ${{ inputs.nodeVersion }} + # Confluent publishes prebuilds up to Node 24 only. + - name: Verify Kafka native binding installed + if: startsWith(inputs.nodeVersion, '24.') + env: + NODES_BASE_PACKAGE_JSON: packages/nodes-base/package.json + run: node .github/scripts/docker/kafka-native-smoke-check.mjs + # cli is the only backend package wired into janitor scoping today, so # the workspace bulk run excludes it and a dedicated step invokes the # scoped variant. This avoids turbo silently no-op'ing `test:unit:changed` diff --git a/package.json b/package.json index 88f16019c53..aee0797821d 100644 --- a/package.json +++ b/package.json @@ -105,6 +105,7 @@ }, "pnpm": { "onlyBuiltDependencies": [ + "@confluentinc/kafka-javascript", "@vscode/ripgrep", "isolated-vm", "sqlite3" @@ -237,7 +238,8 @@ "assert@2.1.0": "patches/assert@2.1.0.patch", "lodash@4.18.1": "patches/lodash@4.18.1.patch", "@langchain/openai@1.4.4": "patches/@langchain__openai@1.4.4.patch", - "@langchain/google-common@2.1.24": "patches/@langchain__google-common@2.1.24.patch" + "@langchain/google-common@2.1.24": "patches/@langchain__google-common@2.1.24.patch", + "@confluentinc/kafka-javascript@1.9.1": "patches/@confluentinc__kafka-javascript@1.9.1.patch" } } } diff --git a/patches/@confluentinc__kafka-javascript@1.9.1.patch b/patches/@confluentinc__kafka-javascript@1.9.1.patch new file mode 100644 index 00000000000..bbec2d40bb3 --- /dev/null +++ b/patches/@confluentinc__kafka-javascript@1.9.1.patch @@ -0,0 +1,13 @@ +diff --git a/package.json b/package.json +index ed972a91dca9ad78b47f1d8d295df58cdef269ff..d8f7499f85c1432cbf62bdbbe01fc12680e8e31c 100644 +--- a/package.json ++++ b/package.json +@@ -10,7 +10,7 @@ + "configure": "node-gyp configure", + "build": "node-gyp build", + "test": "make test", +- "install": "node-pre-gyp install --fallback-to-build", ++ "install": "node-pre-gyp install || echo '[@confluentinc/kafka-javascript] no prebuilt binding for this Node version or platform (see the node-pre-gyp error above), so the Kafka node will not run. Use Node 24 for local Kafka work.'", + "install-from-source": "npm ci && node-pre-gyp install --build-from-source=@confluentinc/kafka-javascript --fallback-to-build", + "prepack": "node ./ci/prepublish.js", + "test:types": "tsc -p ." diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1ccab8030e4..4a06c9fab9a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -816,6 +816,9 @@ overrides: '@zone-eu/mailsplit@<5.4.15': 5.4.15 patchedDependencies: + '@confluentinc/kafka-javascript@1.9.1': + hash: c597d3e3d9d6d0d33588b7dc1e88d55f270ba155721aad464bd7fb03e28f5003 + path: patches/@confluentinc__kafka-javascript@1.9.1.patch '@langchain/google-common@2.1.24': hash: b50436a6c7b0a82d54472dff331ba1b42ab8b816995f83295eef2ee4b482a87d path: patches/@langchain__google-common@2.1.24.patch @@ -6439,7 +6442,7 @@ importers: version: 3.808.0 '@confluentinc/kafka-javascript': specifier: 'catalog:' - version: 1.9.1(encoding@0.1.13) + version: 1.9.1(patch_hash=c597d3e3d9d6d0d33588b7dc1e88d55f270ba155721aad464bd7fb03e28f5003)(encoding@0.1.13) '@e965/xlsx': specifier: 'catalog:' version: 0.20.3 @@ -26037,7 +26040,7 @@ snapshots: dependencies: commander: 13.1.0 - '@confluentinc/kafka-javascript@1.9.1(encoding@0.1.13)': + '@confluentinc/kafka-javascript@1.9.1(patch_hash=c597d3e3d9d6d0d33588b7dc1e88d55f270ba155721aad464bd7fb03e28f5003)(encoding@0.1.13)': dependencies: '@mapbox/node-pre-gyp': 2.0.3(encoding@0.1.13) bindings: 1.5.0 diff --git a/scripts/build-n8n.mjs b/scripts/build-n8n.mjs index 5d7634e5840..c07733649e3 100755 --- a/scripts/build-n8n.mjs +++ b/scripts/build-n8n.mjs @@ -35,7 +35,12 @@ const config = { }; // Define backend patches to keep during deployment -const PATCHES_TO_KEEP = ['pdfjs-dist', 'pkce-challenge', 'bull']; +const PATCHES_TO_KEEP = [ + 'pdfjs-dist', + 'pkce-challenge', + 'bull', + '@confluentinc/kafka-javascript', +]; // #endregion ===== Configuration =====