n8n - ✅(Solved) Fix Bug: pnpm build fails on Node.js 22+ (Apple Silicon / ARM) due to removed buffer.SlowBuffer in [email protected] [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#28207Fetched 2026-04-09 08:16:10
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
commented ×1cross-referenced ×1labeled ×1mentioned ×1

Error Message

ApplicationError: Class could not be found. Please check if the class is named correctly. { className: 'Kafka' }

Root Cause

[email protected]lib/types.js line ~22:

var SlowBuffer = buffer.SlowBuffer; // TypeError on Node 22+

buffer.SlowBuffer was removed in Node.js 22. The fix is already in [email protected] which uses Buffer.allocUnsafeSlow instead.

Fix Action

Fix

PR #28206 adds a pnpm patch for [email protected] that backports this one-line fix:

-var SlowBuffer = buffer.SlowBuffer;
+var SlowBuffer = buffer.SlowBuffer || function SlowBuffer(size) { return Buffer.allocUnsafeSlow(size); };

Workaround

Until the patch lands, you can manually patch the installed file:

node_modules/.pnpm/[email protected]/node_modules/avsc/lib/types.js
# Change line ~22 from:
#   var SlowBuffer = buffer.SlowBuffer;
# To:
#   var SlowBuffer = buffer.SlowBuffer || function SlowBuffer(size) { return Buffer.allocUnsafeSlow(size); };

PR fix notes

PR #28206: build: patch [email protected] to fix buffer.SlowBuffer removal in Node.js 22+

Description (problem / solution / changelog)

Summary

Fixes #28207.

[email protected] (a transitive dependency via @kafkajs/confluent-schema-registry → Kafka node) calls new buffer.SlowBuffer() at module load time. buffer.SlowBuffer was removed in Node.js 22+, causing the n8n-generate-metadata step to crash with a misleading error:

ApplicationError: Class could not be found. Please check if the class is named correctly. { className: 'Kafka' }

This makes the entire n8n-nodes-base build fail for all contributors on Node.js 22+, including anyone on Apple Silicon (M1/M2/M3), despite package.json declaring engines: { node: ">=22.16.0" }.

Fix

A pnpm patch for [email protected] that backports the fix already shipped in [email protected]: uses Buffer.allocUnsafeSlow as a fallback when buffer.SlowBuffer is unavailable.

-var SlowBuffer = buffer.SlowBuffer;
+// buffer.SlowBuffer was removed in Node.js 22+; fall back to Buffer.allocUnsafeSlow
+var SlowBuffer = buffer.SlowBuffer || function SlowBuffer(size) { return Buffer.allocUnsafeSlow(size); };

Alternatives considered

  • Upgrade avsc: [email protected] has this fix natively, but upgrading is a larger change and may introduce other compatibility issues with @kafkajs/confluent-schema-registry.
  • Upgrade @kafkajs/confluent-schema-registry: Depends on upstream adoption of a newer avsc; not yet available.

Related issue

[email protected] uses N-API (prebuild-install -r napi), so its binaries are forward-compatible across Node versions — a binary built for napi 3 or 6 runs on Node 22, 24, and 25 alike. However, the postinstall download can silently fail during pnpm install (e.g. network interruption or pnpm skipping lifecycle scripts), leaving no binary at all. If that happens, prebuild-install -r napi must be run manually from the sqlite3 package directory. Adding a .nvmrc would not fix this, but ensuring pnpm install lifecycle scripts complete successfully would.

Review / Merge checklist

  • PR title and summary are descriptive. (no-changelog)
  • Docs updated or follow-up ticket created. (CONTRIBUTING.md says Node 24+ but package.json engines requires >=22.16.0 — minor inconsistency worth a follow-up)
  • Tests included. (n/a — no meaningful unit test for a removed Node.js API in a transitive dependency; validation is the build passing on Node 22)

Changed files

  • package.json (modified, +2/-1)
  • patches/[email protected] (added, +14/-0)
  • pnpm-lock.yaml (modified, +5/-2)

Code Example

ApplicationError: Class could not be found. Please check if the class is named correctly. { className: 'Kafka' }

---

ApplicationError: Class could not be found. Please check if the class is named correctly. { className: 'Kafka' }

---

var SlowBuffer = buffer.SlowBuffer; // TypeError on Node 22+

---

-var SlowBuffer = buffer.SlowBuffer;
+var SlowBuffer = buffer.SlowBuffer || function SlowBuffer(size) { return Buffer.allocUnsafeSlow(size); };

---

node_modules/.pnpm/avsc@5.7.6/node_modules/avsc/lib/types.js
# Change line ~22 from:
#   var SlowBuffer = buffer.SlowBuffer;
# To:
#   var SlowBuffer = buffer.SlowBuffer || function SlowBuffer(size) { return Buffer.allocUnsafeSlow(size); };
RAW_BUFFERClick to expand / collapse

Bug Description

Running pnpm build fails on Node.js 22+ (including Apple Silicon M1/M2/M3 machines) with a misleading error:

ApplicationError: Class could not be found. Please check if the class is named correctly. { className: 'Kafka' }

The real cause is that [email protected] (a transitive dependency via @kafkajs/confluent-schema-registry → Kafka node) calls new buffer.SlowBuffer() at module load time. buffer.SlowBuffer was removed in Node.js 22+, which causes the n8n-generate-metadata VM isolation step to catch the TypeError and surface it as a misleading "class not found" error.

This affects all contributors trying to build locally on Node.js 22+, despite package.json declaring engines: { node: ">=22.16.0" }.

Steps to Reproduce

  1. Install Node.js 22.x (e.g. via nvm: nvm install 22 && nvm use 22)
  2. Clone the repo and run pnpm install
  3. Run pnpm build

Expected behavior

Build completes successfully.

Actual behavior

n8n-nodes-base:build fails:

ApplicationError: Class could not be found. Please check if the class is named correctly. { className: 'Kafka' }

Stack trace points to loadClassInIsolation catching a TypeError: SlowBuffer is not a constructor from avsc/lib/types.js.

Environment

  • OS: macOS (Apple Silicon / ARM64) — also reproducible on any platform with Node.js 22+
  • Node.js: 22.x (any patch version)
  • pnpm: 10.x

Root Cause

[email protected]lib/types.js line ~22:

var SlowBuffer = buffer.SlowBuffer; // TypeError on Node 22+

buffer.SlowBuffer was removed in Node.js 22. The fix is already in [email protected] which uses Buffer.allocUnsafeSlow instead.

Fix

PR #28206 adds a pnpm patch for [email protected] that backports this one-line fix:

-var SlowBuffer = buffer.SlowBuffer;
+var SlowBuffer = buffer.SlowBuffer || function SlowBuffer(size) { return Buffer.allocUnsafeSlow(size); };

Workaround

Until the patch lands, you can manually patch the installed file:

node_modules/.pnpm/[email protected]/node_modules/avsc/lib/types.js
# Change line ~22 from:
#   var SlowBuffer = buffer.SlowBuffer;
# To:
#   var SlowBuffer = buffer.SlowBuffer || function SlowBuffer(size) { return Buffer.allocUnsafeSlow(size); };

extent analysis

TL;DR

Apply the patch for [email protected] to replace buffer.SlowBuffer with a compatible alternative.

Guidance

  • Identify if you are using Node.js 22+ and [email protected] as a transitive dependency.
  • Consider applying the one-line fix to node_modules/.pnpm/[email protected]/node_modules/avsc/lib/types.js as a temporary workaround.
  • Wait for the PR #28206 patch to be merged and update your dependencies accordingly.
  • Verify the fix by running pnpm build after applying the patch.

Example

-var SlowBuffer = buffer.SlowBuffer;
+var SlowBuffer = buffer.SlowBuffer || function SlowBuffer(size) { return Buffer.allocUnsafeSlow(size); };

This code change replaces the removed buffer.SlowBuffer with a compatible alternative.

Notes

This fix only applies to users of Node.js 22+ and [email protected]. Other versions may not be affected.

Recommendation

Apply the workaround by manually patching the installed file until the patch lands, as upgrading to a fixed version is not currently available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Build completes successfully.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING