Skip to content

Commit fe10e5f

Browse files
committed
fix(workers): do not exit worker process on unhandled rejections
The worker process unhandledRejection handler currently calls process.exit(1) for any rejection whose message is not "expected" / "AssertionError". Exiting the worker silently drops every remaining test in its queue — they do not appear in the failure summary, they are missing entirely from the run report. In real suites this triggers routinely from orphaned promises: - page.waitForResponse() created before an action that throws — the response promise outlives the throw and rejects with Timeout seconds/minutes later, after the scenario has already moved on (or finished). - Session-restore races in the auth plugin when multiple workers cold-cache simultaneously. - Playwright video.saveAs after a context close. Measured on a 133-scenario suite, 4 workers, Node 22: Without this fix: 73 / 133 executed, 2 workers killed → 60 tests silently lost from the report With this fix: 145 / 145 executed, 0 workers killed → all rejections logged, failed tests stay in the report, worker continues to next test Restores 3.x behaviour (workers logged rejections and continued). The uncaughtException handler keeps its current behaviour — that one is genuinely unrecoverable.
1 parent 743f603 commit fe10e5f

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

lib/command/workers/runTests.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ process.on('unhandledRejection', (reason, promise) => {
5454
process.stderr.write(`${reason.stack}\n`)
5555
}
5656

57-
// Don't exit on test-related rejections
58-
if (msg.includes('expected') || msg.includes('AssertionError')) {
59-
return
60-
}
61-
process.exit(1)
57+
// Do not exit on unhandled rejections — log only.
58+
// Exiting kills the entire worker process, silently dropping every remaining
59+
// test in its queue (no failure report, just missing from the run summary).
60+
// Orphaned promises happen routinely in real suites: detached
61+
// page.waitForResponse() that times out after the action threw, session-
62+
// restore races in auth plugins, etc. Restores 3.x behavior where workers
63+
// logged the rejection and continued to the next test.
6264
})
6365

6466
// hide worker output

0 commit comments

Comments
 (0)