fix(test): stop child-process cleanup from masking real test failures - #80
Merged
Merged
Conversation
terminateChild runs from finally blocks, but its SIGKILL path awaited waitForExit without a try/catch. When the exit event was slow to arrive under CI load, cleanup threw and replaced whatever the test had actually asserted. That is what the SIGINT watchdog failure on main was: the reported error was "Timed out waiting for process 16248 to exit" from the cleanup helper, and the 4065ms duration matches its two 2s waits rather than the 15s the test itself budgets. The real outcome of the assertion was never visible. SIGTERM passed in 86ms in the same run, so the process teardown itself was not the problem. Cleanup is now best effort and cannot throw. The SIGKILL wait is also given more room, since SIGKILL cannot be caught and a missing exit event inside the window is a reporting artifact rather than a live process. The harness still reaps by pid afterwards.
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.
What broke
CI went red on main again after #79, on
ralph-watchdog-script.test.ts > exits cleanly on SIGINT.The reported error was
Timed out waiting for process 16248 to exit— but that message comes from the cleanup helper, not the test body:SIGNAL_EXIT_TIMEOUT_MS(what the test itself waits) is 15sterminateChild's two 2s waitsSIGTERMpassed in 86ms in the same run, so process teardown itself was fineRoot cause
terminateChildruns fromfinallyblocks, but its SIGKILL path awaitedwaitForExitwithout a try/catch:When the
exitevent was slow to arrive under CI load, cleanup threw and replaced whatever the test had actually asserted. We never got to see the real outcome.Fix
Cleanup is best-effort and cannot throw. The SIGKILL wait also gets more room: SIGKILL cannot be caught, so a missing
exitevent inside the window is a reporting artifact rather than a process still running. The harness still reaps by pid afterwards viacleanupHarness.Applied to both files carrying this helper (
ralph-watchdog-script.test.ts,ralph-script.test.ts).Note on the previous fix
#79 was still worth doing and is what made this diagnosable. Before it, vitest killed the test at its global 10s timeout with a generic "Test timed out in 10000ms" and no information. After it, the failure surfaced a specific message with a pid — which is what pointed at the cleanup helper rather than the watchdog script.