Repository navigation
test(coding-agent): cover the shutdown recovery path per call site (senpi#3067 L5) - #6146
Conversation
…enpi#3067 L5) L5 of code-yeongyu#3067 only; L1 is code-yeongyu#6118, L2/L3/L4 are untouched, so this does not close code-yeongyu#3067.
|
Thanks @surlymochan. We've queued this for review and will post the findings here. |
|
Thanks @surlymochan. The review at ea49ae0 asks for changes before merge. All three main points are about whether the tests can fail when the behavior regresses:
Smaller items: stubbing |
…ecovery (senpi#3067 L5)
|
Addressed the review at ea49ae0 (all changes in
Smaller items: the 10 s real readiness wait is gone (nothing can kill the child before its handler is installed now that SIGTERM is never delivered); cleanup awaits the shutdown promise with the same bounded loop instead of racing a fixed 5 s real timeout; the dead One thing I did not change, and why: the review asks for the stopWatchers/destroyAll cases to be set up so their own call site drives the recovery reap. That cannot happen without reordering Tests: |
|
Thanks @surlymochan. The review is CLEAR at 62e56cc: SIGTERM order is asserted and each call site now drives its own recovery reap. One note for later: |
|
Merged as d295cca. Thanks @surlymochan! |
Summary
Fixes L5 of #3067 only (test gap for the shutdown-level recovery). L1 is #6118, L2/L3/L4 are untouched, so this PR does not close #3067. Test-only change, no production code touched.
What changed
packages/coding-agent/test/suite/regressions/3067-shutdown-call-sites.test.ts: one test per call site that can throw before the child is signalled (or right after its stop), each showing the child still receives SIGTERM, then SIGKILL, and is reaped, and shutdown still exits 1 with the generation left intact (by design: an unobserved child exit leaves its generation, pointer and settings intact):drain.stopthrows (!childStopStartedpath — the recovery reaps the child);stopWatchersthrows after the child stop;clients.destroyAllthrows after the child stop.RED → GREEN
The tests drive real
performShutdownwith a real SIGTERM-ignoring child and fake timers for the 5 s + 30 s waits (plus a real event-loop turn per slice, so the SIGKILLed child's exit is actually observed — without it the mocked 30 s kill wait fires first and the recovery reports the exit unobserved). Test-only, so there is no pre-fix code failure to show: these are the missing coverage, not a bug fix.Tests
3067-shutdown-call-sites.test.ts— 3 passed.bun run check(oxlint, fmt, tsc, locks) — exit 0.node scripts/check-pr-changelog.mjs --base <merge-base>) — PASS (no runtime source changes detected, no fragment needed for a test-only PR).Out of scope
L2 (wall-clock steps /
/procticks), L3 (once-per-generation logging), L4 (recovery error chaining, #6144) — left for follow-ups.Notes
Summary by cubic
Adds missing test coverage for the shutdown recovery path in
performShutdown(L5 of #3067), with two gradations:drain.stopthrowing before the child is signalled (where the recovery reap drives SIGTERM then SIGKILL), andstopWatchersorclients.destroyAllthrowing after the ordinary child stop. Each test drives a real shutdown with a SIGTERM-ignoring child under fake timers and asserts the child is signalled SIGTERM, then SIGKILL, is reaped, and shutdown exits 1 with the generation left intact. The tests also pin each call site's position in the failure sequence and verify the stop intent distinguishes the recovery reap from the ordinary child stop. Test-only change; there is no fix to exercise, so these tests just document the expected behavior.Written for commit 62e56cc. Summary will update on new commits.