Skip to content

Error instantiating a Kafka client with the Bun runtime #264

Open
@arcoraven

Description

@arcoraven

Environment Information

  • OS: MacOS 15.2, Linux x64
  • Bun version: 1.2.3 and 1.0.0
  • confluent-kafka-javascript version: 1.2.0 and 1.0.0

Steps to Reproduce
Trying to instantiate the KafkaJS client with the Bun runtime throws an error.

index.ts:

import { KafkaJS } from "@confluentinc/kafka-javascript";
new KafkaJS.Kafka({});

Running it with bun run index.ts:

$ bun run index.ts

107 |         return opts[p] || p;
108 |       })
109 |     );
110 |     tries.push(n);
111 |     try {
112 |       b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
                                                     ^
error: The module 'kafka' was compiled against a different Node.js ABI version using NODE_MODULE_VERSION 108. This version of Bun requires NODE_MODULE_VERSION 127. Please try re-compiling or re-installing the module.
      at bindings (/Users/arcoraven/bun-example/node_modules/bindings/bindings.js:112:48)
      at <anonymous> (/Users/arcoraven/bun-example/node_modules/@confluentinc/kafka-javascript/librdkafka.js:10:5)
      at <anonymous> (/Users/arcoraven/bun-example/node_modules/@confluentinc/kafka-javascript/lib/client.js:15:5)
      at <anonymous> (/Users/arcoraven/bun-example/node_modules/@confluentinc/kafka-javascript/lib/kafka-consumer.js:14:5)
      at <anonymous> (/Users/arcoraven/bun-example/node_modules/@confluentinc/kafka-javascript/lib/rdkafka.js:11:5)
      at <anonymous> (/Users/arcoraven/bun-example/node_modules/@confluentinc/kafka-javascript/lib/kafkajs/_producer.js:1:7)
      at <anonymous> (/Users/arcoraven/bun-example/node_modules/@confluentinc/kafka-javascript/lib/kafkajs/_kafka.js:1:19)
      at <anonymous> (/Users/arcoraven/bun-example/node_modules/@confluentinc/kafka-javascript/lib/kafkajs/index.js:5:8)
      at <anonymous> (/Users/arcoraven/bun-example/node_modules/@confluentinc/kafka-javascript/lib/index.js:1:5)

Bun v1.2.3 (macOS arm64)

Does this library depend on Node.js-specific APIs or V8 engine features that aren't yet implemented in Bun's runtime?

confluent-kafka-javascript Configuration Settings
N/A

Additional context

package.json:

{
  "name": "bun-example",
  "module": "index.ts",
  "type": "module",
  "private": true,
  "devDependencies": {
    "@types/bun": "latest"
  },
  "peerDependencies": {
    "typescript": "^5"
  },
  "dependencies": {
    "@confluentinc/kafka-javascript": "1.2.0"
  },
  "trustedDependencies": [
    "@confluentinc/kafka-javascript"
  ]
}

tsconfig.json:

{
  "compilerOptions": {
    // Enable latest features
    "lib": ["ESNext", "DOM"],
    "target": "ESNext",
    "module": "ESNext",
    "moduleDetection": "force",
    "jsx": "react-jsx",
    "allowJs": true,

    // Bundler mode
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "verbatimModuleSyntax": true,
    "noEmit": true,

    // Best practices
    "strict": true,
    "skipLibCheck": true,
    "noFallthroughCasesInSwitch": true,

    // Some stricter flags (disabled by default)
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noPropertyAccessFromIndexSignature": false
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions