Skip to content
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

repro: vmForks bug #6452

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Sep 4, 2024

Description

To run the reproduction: pnpm run node-error-repro. This should run tests and create files with all the output from those tests.

What happens:

  • Vitest spawns several workers to run tests inside of them. One worker will run several tests one after another when it's free.
  • At one point the worker (child_process in the reproduction, because worker_thread crashes the whole process) crashes while trying to import something. I've added console logs in our module runner implementation - it only logs the module if it's not cached already. Every time it crashes it imports the same file it looks like (because the end of the debug is always the same in all files - node_modules/loupe/lib/helpers.js). I don't think that file is the problem, but one of its parents maybe? Usually, it happens at least on the second test run after we create a new executor:
    const executor = await startVitestExecutor({

    Vitest never manually clears the cache, we rely on gc, but we also reuse fileMap cache:
    const fileMap = new FileMap()
  • The problem is most likely with how we implement VM executor - it was based on Jest's with some modifications, but I am not smart enough to figure out why. The error started happening in Node 22.1, but the changelog doesn't really mention related changes

Copy link

netlify bot commented Sep 4, 2024

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit afb83f4
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/66d87dd720a8ad0008b3f0cc
😎 Deploy Preview https://deploy-preview-6452--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AriPerkkio
Copy link
Member

The test/cli/test/vm-threads.test.ts is also failing on CI and locally now. The failure does not happen with Node 22.0, but happens with all versions above 22.1.

ari ~/x/vitest/test/cli (main) $ pnpm run test vm-threads --run

> @vitest/test-cli@ test /Users/x/x/vitest/test/cli
> vitest "vm-threads" "--run"


 RUN  v2.1.1 /Users/x/x/vitest/test/cli

 ❯ test/vm-threads.test.ts (1)
 ❯ test/vm-threads.test.ts (1)
   ⠏ importing files in restricted fs works correctly

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: Worker exited unexpectedly
 ❯ ChildProcess.<anonymous> ../../node_modules/.pnpm/tinypool@1.0.0/node_modules/tinypool/dist/index.js:136:34
 ❯ ChildProcess.emit node:events:531:35
 ❯ ChildProcess._handle.onexit node:internal/child_process:293:12

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 Test Files   (1)
      Tests   (1)
     Errors  1 error
   Start at  09:34:59
   Duration  683ms (transform 43ms, setup 0ms, collect 161ms, tests 0ms, environment 0ms, prepare 46ms)

 ELIFECYCLE  Test failed. See above for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants