-
Notifications
You must be signed in to change notification settings - Fork 1.3k
"Error: Module did not self-register" with Node v12 worker threads #2746
Comments
I tried switching
I sort of expected this to work given that node-sass doesn't have any global state that I can see. Maybe libsass is doing something not thread-safe, but I wouldn't know about that. |
We currently do not support workers - our add on is not context-aware. We are using libuv lowlevel routines and it might be difficult to make it worker-aware. Can you try to produce a backtrace from your crash? |
Hi, I will give this a try! I did build node-sass with debugging on and didn't get much useful, but I'll try some more when I get a chance. It didn't seem like node-sass used much global state, so I naïvely assumed it might be okay if I Just changed to |
We have some static initialization that is done by C++ runtime for us. An example of a problem that was caused by static initialization was this #1283 (comment) However we run libsass code in a background thread (outside of the main JavaScript loop) so maybe there is something we can investigate. |
Fixes a memory leak introduced in sass/libsass@4254054. I do not understand why it leaks without this change but it does seem like a bug in `SharedPtr`. Fixes sass#2746
I'm finding that node-sass is failing to load when I'm using
mocha-parallel-tests
. It turns out that mocha-parallel-tests uses worker threads in Node v12, and that seems to be the reason. The first thread torequire("node-sass")
succeeds, but the second one fails withError: Module did not self-register
.It seems reasonable that someone might want to use node-sass in worker threads, e.g. something similar to
thread-loader
. In my case, I'm running integration tests (in parallel) where some SCSS compilation is part of the thing being tested.Similar error messages have been reported before, but they precede the introduction of worker threads so I presume they are caused to something else.
Minimal reproduction:
Output:
Versions
npm -v
):6.11.2
node -v
):v12.10.0
node -p process.versions
):node -p process.platform
):linux
node -p process.arch
):x64
node -p "require('node-sass').info"
):npm node-sass versions (
npm ls node-sass
):└── node-sass@4.12.0
Binding:
I installed the binding using standard npm install, but I also tried https://github.com/sass/node-sass/releases/download/v4.12.0/linux-x64-72_binding.node (they have the same SHA256 hash anyway)
The text was updated successfully, but these errors were encountered: