Repository navigation
Description
Describe the bug
Running vitest in browser mode fails randomly with this error
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: [vitest] There was an error when mocking a module. If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock
❯ ManualMockedModule.resolve node_modules/.pnpm/@vitest[email protected]_vite@7_9cc983c1a1a6003fbd2eb3c730e00d69/node_modules/@vitest/mocker/dist/chunk-registry.js:160:24
❯ processTicksAndRejections node:internal/process/task_queues:105:5
❯ runNextTicks node:internal/process/task_queues:69:3
❯ process.processImmediate node:internal/timers:459:9
❯ process.callbackTrampoline node:internal/async_hooks:130:17
❯ node_modules/.pnpm/@[email protected]_playw_c44df5d986a1c4ecd74a2ff725a5422e/node_modules/@vitest/browser/dist/webdriver-KA1WiV0q.js:128:35
❯ RouteHandler._handleInternal node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/client/network.js:693:23
❯ RouteHandler._handleImpl node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/client/network.js:662:14
❯ RouteHandler.handle node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/client/network.js:656:12
Caused by: Error: [birpc] rpc is closed, cannot call "resolveManualMock"
❯ Proxy.sendCall node_modules/.pnpm/@[email protected]_playw_c44df5d986a1c4ecd74a2ff725a5422e/node_modules/@vitest/browser/dist/index.js:2881:17
❯ ManualMockedModule.factory node_modules/.pnpm/@[email protected]_playw_c44df5d986a1c4ecd74a2ff725a5422e/node_modules/@vitest/browser/dist/index.js:3218:34
❯ ManualMockedModule.resolve node_modules/.pnpm/@vitest[email protected]_vite@7_9cc983c1a1a6003fbd2eb3c730e00d69/node_modules/@vitest/mocker/dist/chunk-registry.js:158:25
❯ node_modules/.pnpm/@[email protected]_playw_c44df5d986a1c4ecd74a2ff725a5422e/node_modules/@vitest/browser/dist/webdriver-KA1WiV0q.js:128:48
❯ RouteHandler._handleInternal node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/client/network.js:695:7
❯ RouteHandler._handleImpl node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/client/network.js:662:25
❯ node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/client/network.js:656:55
❯ AsyncLocalStorage.run node:internal/async_local_storage/async_hooks:91:14
❯ Zone.run node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/server/utils/zones.js:42:36
❯ NodeZone.run node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/server/utils/nodePlatform.js:57:23
vite config as follows
test: {
testTimeout: 60000,
retry: 3,
globals: true,
screenshotFailures: false,
screenshotDirectory: path.resolve(
__dirname,
'./coverage/test_screenshots',
),
setupFiles: ${srcDirPath}/setupTests.ts,
browser: {
headless: true, // consider true for local dev
provider: 'playwright', // or 'webdriverio'
isolate: true,
enabled: true,
instances: [{ browser: 'chromium' }],
},
maxConcurrency: 20,
isolate: false, // only safe with the poolOptions above
css: false,
deps: {
optimizer: {
web: {
enabled: true,
},
},
},
fileParallelism: true,
pool: 'forks',
poolOptions: {
forks: {
isolate: false,
singleFork: false,
},
},
sequence: {
shuffle: true,
concurrent: false,
},
reporters: ['html', 'verbose', 'vitest-sonar-reporter', 'json'],
outputFile: {
json: '--report.json',
'vitest-sonar-reporter': 'testResults/sonar-report.xml',
},
Reproduction
System Info
System:
OS: Windows 11 10.0.26100
CPU: (18) x64 Intel(R) Core(TM) Ultra 5 135H
Memory: 4.71 GB / 31.43 GB
Binaries:
Node: 22.14.0 -
npm: 10.2.5 -
pnpm: 10.4.1 -
Browsers:
Edge: Chromium (140.0.3485.54), ChromiumDev (141.0.3525.0)
Internet Explorer: 11.0.26100.1882
npmPackages:
@vitejs/plugin-legacy: ^5.4.3 => 5.4.3
@vitejs/plugin-react: ^4.7.0 => 4.7.0
@vitest/browser: ^3.2.4 => 3.2.4
@vitest/coverage-v8: ^3.2.4 => 3.2.4
@vitest/ui: 2.1.9 => 2.1.9
playwright: ^1.56.0 => 1.56.0
vite: ^7.1.10 => 7.1.10
vitest: ^3.2.4 => 3.2.4
vitest-sonar-reporter: ^2.0.4 => 2.0.4Used Package Manager
pnpm
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.
Activity
github-actions commentedon Oct 20, 2025
Hello @emiltsokov. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with
needs reproductionwill be closed if they have no activity within 3 days.