Skip to content

fix(cli): prevent startup metadata hangs after root-help timeouts - #109417

Merged
steipete merged 1 commit into
openclaw:mainfrom
ZengWen-DT:fix/cli-stalled-root-help-renderers
Jul 17, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
ZengWen-DT:fix/cli-stalled-root-help-renderers

Conversation

@ZengWen-DT

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where CLI startup metadata generation, builds, and packaging could remain blocked after the 120-second root-help rendering timeout when the renderer intercepted and ignored the default termination signal.

Why This Change Was Made

Both synchronous root-help render paths now use SIGKILL with their existing timeout so the deadline is a hard bound. The change is limited to the bundled and source root-help subprocesses; the asynchronous command-help renderer keeps its existing TERM-to-KILL process-tree lifecycle.

User Impact

Developers and release operators no longer have to manually terminate metadata generation when a root-help renderer stalls past its timeout. Normal bundled and source help output is unchanged.

Evidence

Real-machine proof was collected on Linux 6.8.0 x86_64 with Node v24.18.0.

Before the production change, the focused test drove both real renderer entry points through a partial node:child_process mock and failed because their exact spawn options had timeout: 120000 but no hard kill signal:

node scripts/run-vitest.mjs test/scripts/write-cli-startup-metadata.test.ts
FAIL ... hard-kills synchronous root help renderers after their timeout
Expected: { "killSignal": "SIGKILL", "timeout": 120000 }
Received: { "timeout": 120000 }
Tests 1 failed | 12 passed

The underlying Node behavior was reproduced with real child processes. The child intercepted SIGTERM and exited on its own after two seconds; the caller requested a 100 ms timeout:

{"label":"default-SIGTERM","elapsedMs":2019,"errorCode":"ETIMEDOUT","signal":null,"status":0}
{"label":"explicit-SIGKILL","elapsedMs":102,"errorCode":"ETIMEDOUT","signal":"SIGKILL","status":null}
{"label":"negative-control","elapsedMs":19,"errorCode":null,"signal":null,"status":0}

This matches the Node spawnSync contract: killSignal defaults to SIGTERM, and the synchronous call continues waiting if the child handles that signal without exiting: https://nodejs.org/api/child_process.html#child_processspawnsynccommand-args-options

After the change, the same focused test confirms both production render paths pass timeout: 120000 and killSignal: "SIGKILL":

node scripts/run-vitest.mjs test/scripts/write-cli-startup-metadata.test.ts
Test Files  1 passed (1)
Tests       13 passed (13)

The real source root-help renderer also completed normally as a production-path negative control:

node --import tsx --input-type=module -e '<invoke __testing.renderSourceRootHelpText()>'
{"firstLine":"","includesUsage":true,"bytes":7058}

Additional validation:

node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.scripts.json scripts/write-cli-startup-metadata.ts
exit 0

./node_modules/.bin/oxfmt --check scripts/write-cli-startup-metadata.ts test/scripts/write-cli-startup-metadata.test.ts
All matched files use the correct format.

git diff --check upstream/main...HEAD
exit 0

Autoreview (.agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output) reported no findings and patch is correct with 0.94 confidence.

Not tested locally: a full bundled build/package run or Windows execution. The regression test covers the exact options for both synchronous entry points; fork CI will provide the broader build and platform-independent checks.

AI-assisted: Codex helped implement and review the change; the real subprocess and production renderer evidence above was run locally.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS labels Jul 16, 2026
@ZengWen-DT
ZengWen-DT force-pushed the fix/cli-stalled-root-help-renderers branch from 6ce5b93 to 970fe8d Compare July 17, 2026 00:20
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 2:27 AM ET / 06:27 UTC.

Summary
The PR adds SIGKILL to the remaining synchronous source root-help renderer timeout, exposes that renderer for testing, and verifies its spawn options.

PR surface: Tests +27, Other +2. Total +29 across 2 files.

Reproducibility: yes. The production path uses spawnSync with the default SIGTERM behavior, and the supplied real-process reproduction demonstrates that a signal-handling child can substantially exceed the requested timeout.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: unknown-data-model-change: test/scripts/write-cli-startup-metadata.test.ts, vector/embedding metadata: test/scripts/write-cli-startup-metadata.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] The PR is currently reported as behind the latest base, so the final merge should use a refreshed exact-head review after the normal three-way update; no concrete conflict or regression is presently shown.

Maintainer options:

  1. Decide the mitigation before merge
    Both synchronous root-help renderers should enforce their existing deadline with an uncatchable kill signal, while asynchronous command-help rendering retains its graceful process-tree shutdown sequence.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed; maintainers can use the normal merge path after refreshing the behind branch and completing required checks.

Security
Cleared: The patch adds no dependency, workflow, secret, permission, downloaded-code, or supply-chain surface, and the forceful signal is limited to an owned build-time child process.

Review details

Best possible solution:

Both synchronous root-help renderers should enforce their existing deadline with an uncatchable kill signal, while asynchronous command-help rendering retains its graceful process-tree shutdown sequence.

Do we have a high-confidence way to reproduce the issue?

Yes. The production path uses spawnSync with the default SIGTERM behavior, and the supplied real-process reproduction demonstrates that a signal-handling child can substantially exceed the requested timeout.

Is this the best way to solve the issue?

Yes. Configuring the existing synchronous subprocess timeout with SIGKILL is the narrowest maintainable repair; it avoids duplicating the more complex asynchronous process-tree supervisor and preserves normal help output.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8fa4867ab43b.

Label changes

Label justifications:

  • P2: The PR fixes a bounded but real build and packaging hang affecting developers and release operators without evidence of a broad core-runtime outage.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR provides after-fix terminal evidence, a real SIGTERM-versus-SIGKILL timing reproduction, focused passing regression coverage, and a successful production-renderer control.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides after-fix terminal evidence, a real SIGTERM-versus-SIGKILL timing reproduction, focused passing regression coverage, and a successful production-renderer control.
Evidence reviewed

PR surface:

Tests +27, Other +2. Total +29 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 28 1 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 2 30 1 +29

What I checked:

  • Changed production surface: The branch adds killSignal: "SIGKILL" beside the existing 120-second timeout in the synchronous source root-help spawnSync call. (scripts/write-cli-startup-metadata.ts:629, c41fd5cb1dbd)
  • Caller and fallback path: Startup metadata generation tries bundled root help first and uses the source root-help renderer as its fallback, so an unbounded synchronous fallback can block build and packaging completion. (scripts/write-cli-startup-metadata.ts:3716, c41fd5cb1dbd)
  • Sibling lifecycle: Asynchronous command-help rendering already has a distinct process-tree lifecycle that attempts graceful termination before force-killing; this PR correctly leaves that sibling behavior unchanged. (scripts/write-cli-startup-metadata.ts:947, c41fd5cb1dbd)
  • Regression coverage: The added test invokes the real source-renderer entry point through a partial child-process mock and asserts both timeout: 120000 and killSignal: "SIGKILL". (test/scripts/write-cli-startup-metadata.test.ts:122, c41fd5cb1dbd)
  • Dependency contract: Node 24 documents that spawnSync sends the configured kill signal on timeout but does not return until the child exits; the default signal is SIGTERM, so a handling child can exceed the requested deadline. citeturn283524view0.
  • Real behavior proof: The PR body records a real child-process run where default SIGTERM took about 2019 ms after a 100 ms timeout, while explicit SIGKILL returned in about 102 ms, followed by passing focused coverage and a normal production-renderer control. (c41fd5cb1dbd)

Likely related people:

  • vincentkoc: The file history shows repeated work on startup-metadata timeouts, parallel help rendering, subprocess-tree cleanup, and related regression coverage. (role: feature owner; confidence: high; commits: 174e771, 286c8e3, dd29a6d; files: scripts/write-cli-startup-metadata.ts, test/scripts/write-cli-startup-metadata.test.ts)
  • steipete: Earlier history includes root-help metadata and timeout work, and the current reviewed head was force-pushed through this account. (role: recent area contributor and head integrator; confidence: medium; commits: 1e6e685, d6b2be9, fbbb4f0; files: scripts/write-cli-startup-metadata.ts, test/scripts/write-cli-startup-metadata.test.ts)
  • yyzquwu: Recent current-main history includes performance work on startup help metadata in the same script. (role: recent adjacent contributor; confidence: medium; commits: 3895c93; files: scripts/write-cli-startup-metadata.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-17T00:27:32.721Z sha 970fe8d8641ca6c34abd656969f2c3897bff0469 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the fix/cli-stalled-root-help-renderers branch from 970fe8d to c41fd5c Compare July 17, 2026 06:21
@steipete
steipete merged commit 9ac2f77 into openclaw:main Jul 17, 2026
100 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

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

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts 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.

3 participants