You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Worker process is never killed when Vitest fails to start, so vitest-vscode processes accumulate #841
When a config fails to start (Vitest failed to start: …), the extension rejects the startup but never kills the spawned worker process or closes its WebSocket server. Every later config reload spawns a new worker for the same config, which fails and also stays alive.
Over a few days of switching git branches I ended up with 49 idle vitest-vscode processes (~100 MB each), all for the same failing config. The extension log showed exactly 49 Vitest failed to start errors for that config.
Reproduction
I observed it with a config that throws during load (a required env var is missing) and with a custom reporter that fails to load (Failed to load custom Reporter from …). I haven't verified the minimal steps below in isolation, but they should hit the same path:
Add a config that throws during load:
// vitest.config.tsimport{defineConfig}from'vitest/config'if(!process.env.REQUIRED_VAR)thrownewError('REQUIRED_VAR not set')exportdefaultdefineConfig({})
Open the workspace. The output shows Vitest failed to start.
Trigger a reload by editing any vitest.config.* (or switching git branches).
pgrep -f vitest-vscode | wc -l grows by one per reload; the processes never exit.
Cause
In createVitestProcess (packages/extension/src/spawn/child_process.ts), the child is only wrapped in ExtensionChildProcess, the class that kills it when the WebSocket closes, on the success path:
waitForWsConnection(wss,pkg,'child_process',options).then((meta)=>{constprocess=newExtensionChildProcess(vitest,server,meta.ws)resolve({ ...meta, process })},reject)// failure: only rejects; `vitest` (child) and `server` stay alive
On a type: 'error' message, onWsConnection (ws.ts) rejects and removes its listeners without closing the socket. The caller only receives the error, so nothing can kill the process, and the worker stays connected forever.
Suggested fix: in the rejection path, kill the child and close the server.
Small related bug in the same finally: vitest.off('exit', onError) should be vitest.off('error', onError).
Environment
vitest.explorer 1.52.2 (same code on main), running in Cursor (VS Code fork)
Activity