-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Running multiple test files crashes when canvas is installed (Error: Module did not self-register: '.../canvas/build/Release/canvas.node'.) #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is caused by the package canvas being installed in my dependencies and used in my tests. JSDom automatically detects the package being present (see https://github.com/jsdom/jsdom#canvas-support) and allows me to test code that relies on Removing it allows me to run multiple tests at once (e.g Interestingly, if ran individually, the tests relying on canvas work fine with Vitest (e.g. |
I have a feeling this might be caused by Automattic/node-canvas#1394. |
workaround: in your config set |
…ttledRefHistory` and `useDebouncedRefHistory` (vitest-dev#740) Co-authored-by: Anthony Fu <[email protected]> Co-authored-by: patak <[email protected]>
Is there any way to use Apparently, npm 7+ always installs I'm using I‘ve tried |
What kind of benefits?
As a workaround, maybe there is an old version of this module that doesn't throw? And you can pin it in your Also, you can try using |
This problem now happens even if you disable threads with |
{
//...
minThreads: 0,
maxThreads: 1,
} in the above example I also tried older versions of UPDATE As we can see here (thanks to @molily) and here TEMPORARY SOLUTION works only if you can uninstall library which included npm ls canvas # we want to see "-- (empty)" here if you see anything other than "empty" try to identify which library included npm uninstall --save canvas LIBRARY_NAME
rm -r node_modules/canvas # just to be sure ;) then remove lock: rm package-lock.json and try again: npm ls canvas # we want to see "-- (empty)" |
If you are running |
Just want to add that because I am also using setup files, having threads turned off has additional performance hits.
|
Seeing a similar issue with sharp
|
@MichaelFBA try calling |
Yes I tried adding it to our global setup file for vitest. The issue seems to occur when running watch and only when you change a test does it break |
Since canvas is an optional peer dependency, we're considering a workaround to just not install peer dependencies locally and in our build agent. This only works for us because we don't have any other optional peer dependencies that we need to use locally or during testing. Though, if you did find yourself in that situation, you could list your optional peer dependencies as explicit dependencies.
|
Found any solution? |
I have had this error in the past with tensorflow and now with onnx runtime. Similar to canvas it seems to be because of a Error: Module did not self-register: '../node_modules/onnxruntime-node/bin/napi-v3/linux/x64/onnxruntime_binding.node'.
❯ Object.<anonymous> ../node_modules/onnxruntime-node/lib/binding.ts:41:5
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: {
"code": "ERR_DLOPEN_FAILED",
}
⎯⎯⎯⎯⎯ |
Had the same problem with |
I ran into this when I had the wrong path for |
@SebCorbin Did you manage to find the issue? I'm also dealing with the same issue with |
I tried all the suggestions, and while disabling threading worked it broke ci. The thing that finally worked for me was blowing away my node_modules deleting the package-lock and clearing the npm cache. Then finally reinstalling everything. |
I'm also still having issues with this. This is not completely fixed.
|
This is package's limitation, not Vitest. |
Describe the bug
I’ve started exprimenting with Vitest and got all tests to pass individually; however, running
npx vitest run .
(or any set of test files together likenpx vitest run src/*.test.js
) crashes with the following error:I’ve removed the
node_modules
directory contents several times, re-installed the dependencies, and the issue still happens. I’m writing this only because that’s the only tangible workaround I found for this problem.Reproduction
Expected behavior:
Test suite runs with all tests passing.
Actual behavior:
Vitest crashes and no tests are run.
Workaround: turn off threads
In #740 (comment), a workaround was presented. Turning off threads stops the issue from happening. Using the following configuration, the tests start working:
Notes
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: