-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
worker.terminate() never resolves #54
Comments
Hey, Thank you so much! @AriPerkkio any idea? |
Is your codebase using any native node addons, either directly or through dependencies? The segmentation fault crash would indicate that there is a native code running that's trying to access invalid memory. Try following command to check the dependencies: $ find node_modules -iname "*.node" We've seen couple of similar reports earlier and after debugging these for long time I don't think these are caused by Vitest or Tinypool. It's simply the code that is run in When you run into these cases in Vitest you could try to move the specific test case to be run in import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
poolMatchGlobs: [
// These tests crash node:worker_threads. Run them in node:child_process instead.
['**/path/some.test.ts', 'child_process'],
],
},
}) @fox1t if you end up finding a solution for this or to make a small reproduction case I'm happy to look into it. |
@AriPerkkio Thank you so much for the explanation. |
@AriPerkkio and @Aslemammad thank you both. You pointed me in the right direction. Now I know the issue, but cannot reproduce it in isolation. First, our private codebase is complex (it is a monorepo), and this will likely not affect many other users. The issue manifests when a Vitest mock of a
The spawn of the worker thread for such a case is very slow, and after the test finishes, it goes into a seg fault. As I said, I tried to reproduce it in isolation without success. So for the moment I used a mix of imports rework and poolMatchGlobs to make the tests pass. If you have more ideas on how we can isolate it, I can make other tries. Thanks again for your help! |
Maybe you can ignore that file in the original vitest run, and spawn another vitest instance after finishing the original one which only runs that file! |
One thing I've noticed with mocks is that starting in about Node 16, the timing of a synchronous return from an asynchronous method is different. I had to fix a couple of tests where I was relying on order of operations and it was causing issues. I'm wondering if that's what you're seeing here. |
This should be fixed in Node v21: nodejs/node#51526 Feel free to open new issue with minimal reproduction case if you still run into this. |
Premise
I am facing a weird issue only on Ubuntu 22.04 when using Vitest. I am opening the issue here because, after a deep investigation, it turned out that it is somehow related to the tinypool worker.
Since the codebase affected by the issue is private, I'll explain the behavior here and try tomorrow to provide a repro repo (I am not sure this is even feasible).
The issue
Several test files prevent Vitest from printing the report (default report), even if the test inside the files passes. The process goes in segmentation fault instead of exiting.
I added several
console.logs
in vitest and tinypool codebase to understand where things are breaking. It turned out that the Promise at https://github.com/tinylibs/tinypool/blob/main/src/index.ts#L486 was never resolved.Those are the console log I added:
This is the output when the this issue is present:
On the other hand this is the output when there is no segfault
Vitest version v0.30.1
Tinypool version 0.40.0
Would you happen to have any ideas why this is happening or what I can do to understand the underlying issue better? Do you think this is a vitest bug?
The text was updated successfully, but these errors were encountered: