Open Somebi opened 5 years ago
Node version?
node addons have to explicitly support workers for them to work in that scenario. The main reason for this is that some addons can have global state which would not work for multiple threads.
V10.10 don't remember for sure.
пт, 1 мар. 2019 г., 17:27 mscdex notifications@github.com:
node addons have to explicitly support workers for them to work in that scenario. The main reason for this is that some addons can have global state which would not work for multiple threads.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mscdex/node-xxhash/issues/26#issuecomment-468702579, or mute the thread https://github.com/notifications/unsubscribe-auth/AAc7oaI6KkJryXwxystvT-bulHkHbMdmks5vSUbbgaJpZM4bZDHs .
But calling require not in the global scope, works without errors. Problem exists only when define module in the top most place (i.e. global scope)
вс, 3 мар. 2019 г., 10:13 Denis Abramov somebi@gmail.com:
V10.10 don't remember for sure.
пт, 1 мар. 2019 г., 17:27 mscdex notifications@github.com:
node addons have to explicitly support workers for them to work in that scenario. The main reason for this is that some addons can have global state which would not work for multiple threads.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mscdex/node-xxhash/issues/26#issuecomment-468702579, or mute the thread https://github.com/notifications/unsubscribe-auth/AAc7oaI6KkJryXwxystvT-bulHkHbMdmks5vSUbbgaJpZM4bZDHs .
Can you show an example of each?
I have meet same issue when tried to require xxhash in thread (node v12.8.1, pull/30 applied). But was able to solve it by changing src/hash.cc:
11c11,13
< NODE_MODULE(addon, Init);
---
> NODE_MODULE_INIT() {
> Init(exports);
> }
and re-build binary: cd build && make
Code to reproduce the issue:
(async () => {
const { job, start, stop } = require('microjob');
var XXHash = require('xxhash')
await start();
await job(() => {
var XXHash = require('xxhash')
})
})()
Getting this error... removing node_modules or npm rebuild is not helping. This error is thrown when i'm using threads (workers)