Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Request: Support Node Worker Threads using NAN_MODULE_WORKER_ENABLED #258

Open
Labels
enhancementNew feature or request
@nhr-one

Description

Hello,

I recently ran into an issue with the library when running unit tests using vitest with the --pool=threads option, which uses multiple worker threads to run tests. In my use case, I was getting the following error:

Error: Module did not self-register: '/{local_path}/node_modules/.pnpm/@confluentinc+kafka-javascript@1.2.0/node_modules/@confluentinc/kafka-javascript/build/Release/confluent-kafka-javascript.node'.
 ❯ Module.Hook.Module.require node_modules/.pnpm/dd-trace@5.20.0/node_modules/dd-trace/packages/dd-trace/src/ritm.js:97:33
 ❯ bindings node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js:112:48
 ❯ Object.<anonymous> node_modules/.pnpm/@confluentinc+kafka-javascript@1.2.0/node_modules/@confluentinc/kafka-javascript/librdkafka.js:10:32

After some digging, I found this related StackOverflow question - based on their solution, the only change to fix this issue in the library would be changing the following line:

NODE_MODULE(kafka, Init)

to

NAN_MODULE_WORKER_ENABLED(kafka, Init)

Is this something that can be added to the library? In the meantime, I can change my testing implementation to use --pool=forks option instead, but I would imagine that using the library in worker threads is something that others would find useful at some point.

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

        AltStyle によって変換されたページ (->オリジナル) /