Skip to content
This repository has been archived by the owner on Jun 6, 2021. It is now read-only.

Worker Threads: "Module did not self-register" #78

Closed
mattolson opened this issue Oct 24, 2018 · 6 comments
Closed

Worker Threads: "Module did not self-register" #78

mattolson opened this issue Oct 24, 2018 · 6 comments

Comments

@mattolson
Copy link

When using the new experimental worker threads in Node 10.5 and above, if you require iltorb in both the parent and the worker, the following error is thrown:

Error: Module did not self-register.
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/matt.olson/workspace/storefront-renderer/node_modules/iltorb/index.js:10:40)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)

This seems to be related to nodejs/node#21783 and nodejs/node#21481. I believe the issue is that the module needs to be context-aware.

I ran into a similar issue with the lzo package and have a PR open for it. We will need to do something similar here.

@nstepien
Copy link
Owner

@mattolson Thanks for reporting this issue! Could you double-check if the fix on master works for you?

@nstepien nstepien reopened this Oct 24, 2018
@nstepien
Copy link
Owner

nstepien commented Oct 24, 2018

It looks like NAPI_MODULE_INIT is not available for Node 6 and 8, I wonder if it'll get backported.
I reverted the fix for now.

nstepien added a commit that referenced this issue Oct 26, 2018
This allows iltorb to be loaded multiple times during the lifetime of the Node.js process.

Fix #78
@mattolson
Copy link
Author

@MayhemYDG Thanks!

@mattolson
Copy link
Author

This is working for me, can you create a new release?

@nstepien
Copy link
Owner

I've been waiting for AppVeyor to suport Node 11, but I guess we'll have to do without it. I'll do a release in the evening.

@nstepien
Copy link
Owner

@mattolson 2.4.1 is now published

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants