fix(codeceptjs): prevent IPC race and hang in test utils on Windows/Node 26#1504
Merged
todti merged 4 commits intoJun 1, 2026
Merged
Conversation
…ode 26
On Windows with Node 26, a synchronous throw inside a page-object step
helper caused the forked CodeceptJS process to either:
- hang indefinitely (the 'exit' event never fired), making the vitest
test time out at 5 000 ms; or
- exit before all pending IPC messages were dispatched to the parent,
resulting in 0 collected test results.
Two targeted fixes in test/utils.ts:
1. Kill timeout (30 s): sends SIGTERM to the child process if it does
not exit on its own, preventing the hang.
2. setImmediate drain: yields to the event loop once after 'exit'
before reading messageReader.results, letting any IPC message
callbacks that are already queued run first.
pratushnyi
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Test midweight (26, windows-latest)was flakily failing onpageObject.test.ts > should report broken steps in page objects for raw errors. Two failure modes were observed:exitevent on the forked CodeceptJS process never fired, sorunCodeceptJsInlineTestnever resolved. Vitest killed the test after 5 000 ms.messageReader.results.testswas empty. Theexitevent fired before all pending IPC messages (sent viaprocess.send()in the child) were dispatched to the parent'smessagelistener.Root cause: on Windows + Node 26, a synchronous throw inside a page-object step helper triggers an unhandled-exception path in CodeceptJS that either stalls the process or causes it to exit before the IPC channel is fully drained. The same code path works fine on Linux.
Fix
Two targeted changes to
test/utils.ts(no production code touched):setTimeout(kill, 30_000)— send SIGTERM if the child does not exit on its ownawait new Promise(r => setImmediate(r))before reading results — yield to the event loop once afterexitTesting
All 6 tests in
pageObject.test.tspass locally. The hang/race is Windows-specific and will be confirmed by CI.