-
Couldn't load subscription status.
- Fork 23
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:
confluent-kafka-javascript/src/binding.cc
Line 76 in 26710e6
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.