Open asztal opened 5 years ago
I tried switching NODE_MODULE
for NAN_MODULE_WORKER_ENABLED
- it compiles, works, and only segfaults 10% of the time! OK, maybe 25%. I'm counting that as a success anyway :shipit:
lee@lee-desktop:~/Work/restapi$ node sassbug.js
b {
font-weight: bold; }
Segmentation fault (core dumped)
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 NAN_MODULE_WORKER_ENABLED
- but it's been a long time since I wrote any node native modules and it's changed a lot :)
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 https://github.com/sass/node-sass/issues/1283#issuecomment-169845062
However we run libsass code in a background thread (outside of the main JavaScript loop) so maybe there is something we can investigate.
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 version (
npm -v
):6.11.2
Node version (
node -v
):v12.10.0
Node Process (
node -p process.versions
):Node Platform (
node -p process.platform
):linux
Node architecture (
node -p process.arch
):x64
node-sass version (
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)