-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
'Closing rpc while "fetch" was pending' on v4 beta #8649
Description
Describe the bug
While trying to upgrade a project from Node 23.11.1 to 24.9.0, I initially ran into some issues with tests interacting with msw (specifically getting a bunch of TypeError: RequestInit: Expected signal ("AbortSignal {}") to be an instance of AbortSignal. which was fixed by #8390 in v4 beta). However, I then also ran into different issues with the v4 beta that I'm not seeing in v3 and so I thought to report them.
With 4.0.0-beta.13 installed, the tests become flaky: they sometimes pass and sometimes fail. Regardless of whether they pass or fail, they always print error messages including the string Closing rpc while "fetch" was pending (from
| reject(new Error(`[vitest-worker]: Closing rpc while "${method}" was pending`)) |
As far as I can tell, the tests always pass when turning off parallelization with maxWorkers: 1 and sometimes fail when leaving parallelization on.
With parallelization turned off, the following error message mentioned is printed and tests pass:
Error
stderr | triggerError (file:/Users/me/project/node_modules/vue-router/dist/vue-router.mjs:3623:21)
Error: [vitest-worker]: Closing rpc while "fetch" was pending
at reviveInvokeError (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:473:14)
at Object.invoke (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:489:33)
at VitestModuleRunner.getModuleInformation (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1052:7)
at request (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1069:83)
at /Users/me/project/node_modules/package/Button.vue:2:31
at VitestModuleEvaluator.runInlinedModule (file:///Users/me/project/node_modules/vitest/dist/module-evaluator.js:136:4)
at VitestModuleRunner.directRequest (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1112:59)
at VitestModuleRunner.cachedRequest (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1030:73)
at /Users/me/project/src/views/profile/ProfileListView.vue:69:1
at VitestModuleEvaluator.runInlinedModule (file:///Users/me/project/node_modules/vitest/dist/module-evaluator.js:136:4) {
runnerError: Error: RunnerError
at reviveInvokeError (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:474:64)
at Object.invoke (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:489:33)
at VitestModuleRunner.getModuleInformation (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1052:7)
at request (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1069:83)
at /Users/me/project/node_modules/package/Button.vue:2:31
at VitestModuleEvaluator.runInlinedModule (file:///Users/me/project/node_modules/vitest/dist/module-evaluator.js:136:4)
at VitestModuleRunner.directRequest (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1112:59)
at VitestModuleRunner.cachedRequest (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1030:73)
at /Users/me/project/src/views/profile/ProfileListView.vue:69:1
at VitestModuleEvaluator.runInlinedModule (file:///Users/me/project/node_modules/vitest/dist/module-evaluator.js:136:4)
}
Error: [vitest-worker]: Closing rpc while "fetch" was pending
at reviveInvokeError (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:473:14)
at Object.invoke (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:489:33)
at VitestModuleRunner.getModuleInformation (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1052:7)
at request (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1069:83)
at /Users/me/project/node_modules/package/Button.vue:2:31
at VitestModuleEvaluator.runInlinedModule (file:///Users/me/project/node_modules/vitest/dist/module-evaluator.js:136:4)
at VitestModuleRunner.directRequest (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1112:59)
at VitestModuleRunner.cachedRequest (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1030:73)
at /Users/me/project/src/views/profile/ProfileListView.vue:69:1
at VitestModuleEvaluator.runInlinedModule (file:///Users/me/project/node_modules/vitest/dist/module-evaluator.js:136:4) {
runnerError: Error: RunnerError
at reviveInvokeError (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:474:64)
at Object.invoke (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:489:33)
at VitestModuleRunner.getModuleInformation (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1052:7)
at request (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1069:83)
at /Users/me/project/node_modules/package/Button.vue:2:31
at VitestModuleEvaluator.runInlinedModule (file:///Users/me/project/node_modules/vitest/dist/module-evaluator.js:136:4)
at VitestModuleRunner.directRequest (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1112:59)
at VitestModuleRunner.cachedRequest (file:///Users/me/project/node_modules/vite/dist/node/module-runner.js:1030:73)
at /Users/me/project/src/views/profile/ProfileListView.vue:69:1
at VitestModuleEvaluator.runInlinedModule (file:///Users/me/project/node_modules/vitest/dist/module-evaluator.js:136:4)
}
With parallelization left on, the following errors are printed at the end of the test run (in addition to the ones printed during the tests I mentioned above):
Error
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Vitest caught 13 unhandled errors during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: [vitest-worker]: Closing rpc while "fetch" was pending
❯ reviveInvokeError node_modules/vite/dist/node/module-runner.js:473:14
❯ Object.invoke node_modules/vite/dist/node/module-runner.js:489:33
❯ VitestModuleRunner.getModuleInformation node_modules/vite/dist/node/module-runner.js:1052:7
❯ request node_modules/vite/dist/node/module-runner.js:1069:83
This error originated in "src/views/MyView.spec.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
This error was caught after test environment was torn down. Make sure to cancel any running tasks before test finishes:
- cancel timeouts using clearTimeout and clearInterval
- wait for promises to resolve using the await keyword
Unfortunately, the issue is difficult to reproduce minimally because it reproduces more frequently the more tests are executed in parallel. I'm seeing this issue in a private project, and the 80 tests across 25 test files don't commonly reproduce the issue either and as soon as I start running smaller subsets of the tests (e.g. npx vitest run src/views/**/*UpdateView.spec.ts or npx vitest run src/views/module-1), the issue almost never reproduces.
Nevertheless, I did manage to reproduce the issue in isolation but keep in mind that it might be quite rare.
Notes:
- I noticed that the failure rate decreases if at the start of tests that mount vue components with router interactions, I call
await router.push("/"). Still, the tests fail occasionally. I didn't really expect this to "fix" anything anyway of course.
Reproduction
System Info
Binaries:
Node: 23.11.1 - ~/.local/share/mise/installs/node/23.11.1/bin/node
npmPackages:
@vitejs/plugin-vue: 6.0.1 => 6.0.1
vite: 7.1.7 => 7.1.7
vitest: 4.0.0-beta.13 => 4.0.0-beta.13Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.