Skip to content

Commit fff3329

Browse files
dorlugasigalCopilot
andcommitted
fix(test): force-exit routes.test.js worker on Windows after suite completes
After all Routes subtests finish, node-pty's conpty_console_list_agent.js helper process can crash with `AttachConsole failed` and keep stdio pipes dangling on the test worker, preventing it from exiting before the per-file --test-timeout (180s) fires. The whole file then gets marked as failed even though every individual assertion passed. The earlier --test-force-exit flag (added to npm test) only acts on the parent test runner — it has no effect on per-file workers under --test-isolation=process. Targeted Windows-only after() hook now schedules a process.exit(0) with a 1.5s unref'd grace period, letting in-flight pty.kill IPC settle before forcing the worker out. Non-Windows runs keep full process-leak detection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ec9432f commit fff3329

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/server/routes.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4976,4 +4976,25 @@ describe('Routes', () => {
49764976
});
49774977
},
49784978
);
4979+
4980+
/*
4981+
* Windows-only worker-exit shim. After every Routes subtest completes,
4982+
* node-pty's `conpty_console_list_agent.js` helper process can crash with
4983+
* `AttachConsole failed` and keep our test worker's event loop alive on
4984+
* dangling stdio pipes. The per-file --test-timeout (180s) then fires
4985+
* and marks the WHOLE file as failed even though every assertion passed.
4986+
*
4987+
* `--test-force-exit` doesn't help here — that flag only acts on the
4988+
* parent test runner, not on per-file worker processes.
4989+
*
4990+
* After every test in this file has reported, force-exit the worker
4991+
* itself with a brief grace period for any in-flight `pty.kill()`
4992+
* IPC to settle. Skipped on non-Windows so we still get full process
4993+
* leak detection on Linux/macOS.
4994+
*/
4995+
if (process.platform === 'win32') {
4996+
after(() => {
4997+
setTimeout(() => process.exit(0), 1500).unref();
4998+
});
4999+
}
49795000
});

0 commit comments

Comments
 (0)