This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Make module context-aware #101
Copy link
Copy link
Open
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: https://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: https://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
I've been experimenting with worker threads in node.js recently and noticed that the node-oniguruma module does not appear to be context-aware. In other words, the module will load/instantiate once, but as soon as another thread attempts to require oniguruma for it's own use, the following error is thrown:
Error: Module did not self-register.
at Object.Module._extensions..node (internal/modules/cjs/loader.js:840:18)
at Module.load (internal/modules/cjs/loader.js:666:32)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
at Function.Module._load (internal/modules/cjs/loader.js:598:3)
at Module.require (internal/modules/cjs/loader.js:705:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (~/node_modules/canvas/lib/bindings.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:799:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
at Module.load (internal/modules/cjs/loader.js:666:32)
Steps to Reproduce
In main thread...
const {Worker} = require('worker_threads');
var worker1 = new Worker('./child-thread.js');
var worker2 = new Worker('./child-thread.js');
// etc.In child-thread.js...
{OnigRegExp, OnigScanner} = require 'oniguruma'
scanner = new OnigScanner(['c', 'a(b)?'])
// etc.Expected behavior:
No error
Actual behavior:
Error
Reproduces how often:
100%
Versions
n.a
Additional Information
https://nodejs.org/api/addons.html#addons_context_aware_addons
yogeshbiz
Metadata
Metadata
Assignees
Labels
No labels