Repository navigation
fix(test): keep post-ready shutdown on native timers - #149835
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 3:32 AM ET / 07:32 UTC (Revision 2). ClawSweeper reviewWhat this changesThe Gateway startup test keeps shutdown on native timers and limits fake timers to checking that startup settlement schedules no work after close. Merge readiness✅ Ready for maintainer review This remains a useful, focused test repair: current main retains the problematic timer scope, and no blocking correctness findings remain. The prior review’s empty finding list remains appropriate. Priority: P2 Review scores
Verification
How this fits togetherGateway startup releases background maintenance after deferred initialization finishes. This test exercises startup and shutdown together, including cleanup of the separate local update probe. flowchart TD
A[Gateway test starts server] --> B[Deferred startup pending]
B --> C[Begin shutdown with native timers]
C --> D[Release background waiters]
D --> E[Settle startup with fake timers]
E --> F[Assert no new timers]
F --> G[Restore native timers and join cleanup]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +6. Total +6 across 1 file. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Preserve the real Gateway lifecycle test while isolating fake-clock observation from process cleanup. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the trigger: close overlaps an update-probe subprocess while fake timers freeze exit observation. The author reports before/after reproduction; this review did not execute it. Is this the best way to solve the issue? Yes. Narrowing fake timers preserves the lifecycle assertions without weakening cleanup, increasing timeouts, adding retries, or changing production code. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f000b487300b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
Related: #149417
What Problem This Solves
Fixes a 120-second timeout in the Gateway post-ready startup test when shutdown overlaps a local update-status Git probe.
User Impact
No runtime behavior changes. This removes a test-induced deadlock from compact CI checks.
Why This Change Was Made
The closing case enabled fake timers before calling
server.close(), then awaited all shutdown work without advancing the clock. Gateway readiness does not join the separate local update probe. When close aborts an in-flight probe, process-tree cleanup schedules a 25 ms exit-observation timer (src/process/exec-termination.ts:157); freezing that timer strands the shutdown join even after the process exits.Keep native timers while initiating and joining close. Limit fake timers to resolving the synthetic startup promise, explicitly await
server.startupSettled, and assert that this transition schedules zero timers. Restore native timers infinally. All assertions remain; the test timeout and existing grace-period waits are unchanged.Evidence
The original failure is run 35061613128, job 104683067494,
checks-node-compact-large-11, on a CI-routing-only branch. The last work log waspost-ready.context-window-cacheat 06:10:23.715 UTC, followed by 30/60/90-second no-output notices and the closing case's 120009 ms timeout at 06:12:18.378 UTC. Its preceding settling case passed in 2482 ms.A bounded 24-hour REST scan (2026-09-15 06:20:20 through 2026-09-16 06:20:20 UTC; 92 API attempts) sampled 21/41 failed main CI runs and 12/1077 failed PR CI runs across the window, plus the supplied run. Of 38 failed compact jobs, 37 logs downloaded; only the supplied job mentioned this test. One log was unavailable due to a proxy HTTP 500. This is a sample, not an exhaustive recurrence count; absence from other failed-job logs does not establish that this test passed there.
checks-node-compact-large-11)blacksmith-16vcpu-ubuntu-2404Local proof used the unchanged command
node scripts/run-vitest.mjs src/gateway/server-startup-post-ready.test.tseight times before and eight times after:A disposable diagnostic held an update-probe subprocess open through close and captured the exact stack from
server.close()through update-check cancellation to the frozen exit-observation timer. The post-ready barrier had already released. A separate real-process probe showed the child exited while cleanup remained pending until that timer ran. The repaired Gateway test passed with the same held update probe. Diagnostic instrumentation and logs remain outside the committed diff.Seven sibling files passed, totaling 207 tests: startup lifetime, post-attach, early runtime, handler prewarm, runtime services, idle tasks, and shutdown. Independent local and committed-branch reviews found no actionable P0–P2 findings.
node scripts/check-changed.mjsandgit diff --checkpassed.Exact-head CI run 35067071179 succeeded on attempt 1 for
f00a76ac630ce5109c63b98dca5beb302e706b71. The repaired test passed both cases in job 104699844148; the closing case completed in 1801 ms. No CI reruns were requested.