yfinkelstein / node-zookeeper

node.js client for Apache Zookeeper
MIT License
479 stars 111 forks source link

Error: Module did not self-register #314

Open samuel-zhen opened 2 years ago

samuel-zhen commented 2 years ago

Describe the bug Importing package in both main and worker thread will cause Error: Module did not self-register. It will works if only main or worker thread is importing the package.

To Reproduce main.js

import { Worker } from 'worker_threads';
import ZooKeeper from 'zookeeper';

console.log('Hi from main.js!');
const worker = new Worker('./worker.js');

worker.js

import ZooKeeper from 'zookeeper';

console.log('Hi from worker.js!');

package.json

{
  "name": "zk-worker-thread",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "start": "node main.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "zookeeper": "^5.4.0"
  }
}

Screenshots image

Desktop (please complete the following information):

Additional context Hopefully this thread can provide some clue. https://github.com/nodejs/node/issues/21783

DavidVujic commented 2 years ago

Thank you for reporting!

The Node Worker thing isn't fully supported in this library yet.

samuel-zhen commented 2 years ago

Thanks for the clarification.