Skip to content

fix(test): keep post-ready shutdown on native timers - #149835

Merged
steipete merged 1 commit into
mainfrom
fix/gateway-post-ready-startup-flake
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/gateway-post-ready-startup-flake

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

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 in finally. 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 was post-ready.context-window-cache at 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.

Observed run Job Runner label Reported VM CPUs Result
35061613128 104683067494 (checks-node-compact-large-11) blacksmith-16vcpu-ubuntu-2404 4 closing case timed out at 120009 ms

Local proof used the unchanged command node scripts/run-vitest.mjs src/gateway/server-startup-post-ready.test.ts eight times before and eight times after:

Repetition Before After
1 Pass Pass
2 Pass Pass
3 Pass Pass
4 Closing case timed out at 120035 ms Pass
5 Pass Pass
6 Pass Pass
7 Pass Pass
8 Pass Pass

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.mjs and git diff --check passed.

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.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 07:08
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 3:32 AM ET / 07:32 UTC (Revision 2).

ClawSweeper review

What this changes

The 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
Reviewed head: f00a76ac630ce5109c63b98dca5beb302e706b71

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with preserved assertions, a supported causal explanation, before/after validation, and successful exact-head CI.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied maintainer classification exempts this test-only PR from contributor runtime proof. Its evidence nevertheless exercises real Gateway close with a held update probe and reports recovery after narrowing fake timers; exact-head CI success was independently verified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied maintainer classification exempts this test-only PR from contributor runtime proof. Its evidence nevertheless exercises real Gateway close with a held update probe and reports recovery after narrowing fake timers; exact-head CI success was independently verified.
Evidence reviewed 7 items Verified introduced change: The pinned merge-base-to-head diff changes only timer scope in the closing test case. It preserves maintenance and barrier assertions, explicitly awaits startup settlement, and restores native timers before joining shutdown.
Startup and shutdown contract: The startup continuation checks closePreludeStarted before creating its timer. Close starts the prelude and releases background waiters before awaiting cleanup, so observing startup settlement does not require completing shutdown.
Native timer dependency: Process-tree termination observes exit using a repeating timeout of at most 25 ms; its settlement promise waits for that observation. Gateway close aborts and joins update-check work, supporting the reported frozen-clock deadlock mechanism.
Findings None None.
Security None None.

How this fits together

Gateway 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +6. Total +6 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 11 5 +6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 11 5 +6

Review metrics

None.

Technical review

Best 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.

Labels

Label justifications:

  • P2: Repairs a source-supported intermittent Gateway test deadlock with limited operational scope and no runtime behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied maintainer classification exempts this test-only PR from contributor runtime proof. Its evidence nevertheless exercises real Gateway close with a held update probe and reports recovery after narrowing fake timers; exact-head CI success was independently verified.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff changes only timer scope in the closing test case. It preserves maintenance and barrier assertions, explicitly awaits startup settlement, and restores native timers before joining shutdown. (src/gateway/server-startup-post-ready.test.ts:85, f00a76ac630c)
  • Startup and shutdown contract: The startup continuation checks closePreludeStarted before creating its timer. Close starts the prelude and releases background waiters before awaiting cleanup, so observing startup settlement does not require completing shutdown. (src/gateway/server-start.ts:111, f00a76ac630c)
  • Native timer dependency: Process-tree termination observes exit using a repeating timeout of at most 25 ms; its settlement promise waits for that observation. Gateway close aborts and joins update-check work, supporting the reported frozen-clock deadlock mechanism. (src/process/exec-termination.ts:157, f00a76ac630c)
  • Current-main necessity and release boundary: Fetched main still enables fake timers before server.close() and joins shutdown before restoring them. The latest supplied release, v2026.9.4, does not contain this test file; no shipped fix or merged replacement was established. (src/gateway/server-startup-post-ready.test.ts:85, f000b487300b)
  • Feature-history routing: Main history and the exact recorded-parent comparison connect the existing test to Peter Steinberger’s prior startup work; routing is supported independently of authorship of this proposed patch. (src/gateway/server-startup-post-ready.test.ts:53, 6b07b94b4031)
  • Validation evidence: The captured PR body reports one timeout in eight before runs, eight successful after runs, a held-update-probe diagnostic, and 207 passing sibling tests. GitHub independently confirms run 35067071179 succeeded on attempt 1 at the reviewed head. Raw job-log retrieval was blocked by the artifact-host allowlist, so individual timings remain author-reported. No tests were executed during this read-only review. (f00a76ac630c)

Likely related people:

  • Peter Steinberger: Raw commit 6b07b94 adds src/gateway/server-startup-post-ready.test.ts:53 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6b07b94b4031; files: src/gateway/server-startup-post-ready.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-16T07:15:01.978Z sha f00a76a :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 00ac1bc into main Sep 16, 2026
175 checks passed
@steipete
steipete deleted the fix/gateway-post-ready-startup-flake branch September 16, 2026 07:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant