Repository navigation
fix(test): capture child diagnostics before CLI deadlock cleanup - #150288
Conversation
Collect bounded child resource diagnostics before deadlock cleanup while preserving the original timeout and interaction failures. Keep production logging and output-drain behavior unchanged. Related: #150244
|
🦞👀 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, 4:40 PM ET / 20:40 UTC. ClawSweeper reviewWhat this changesThe CLI test harness captures child resource diagnostics before terminating stalled processes and preserves the original failure when cleanup also fails. Merge readiness✅ Ready for maintainer review Useful diagnostic work remains absent from current main. The bounded capture and cleanup changes have no identified blocking defect, and the linked Windows cleanup PR addresses a separate path. Priority: P3 Review scores
Verification
How this fits togetherCLI process tests launch isolated Node processes and collect their exit status and output. This harness controls their deadlock deadline and supplies failure details to the test runner. flowchart TD
A[CLI process test] --> B[Child process with diagnostic preload]
B --> C{Finished before deadline?}
C -->|Yes| D[Return exit status and output]
C -->|No| E[Request resource diagnostics]
E --> F[Bounded grace and process cleanup]
F --> G[Report timeout with diagnostics and output]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +183. Total +183 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep diagnostic collection in the shared test harness while preserving the deadline, bounded cleanup, and production CLI exit behavior. Do we have a high-confidence way to reproduce the issue? Not applicable to this diagnostic-only improvement. The held-child timeout is demonstrated in the supplied trace; the original intermittent CLI stall remains unreproduced. Is this the best way to solve the issue? Yes. Extending the existing child harness supplies missing evidence without speculatively changing production cleanup or weakening timeout assertions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e1658b84e202. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
) Collect bounded child resource diagnostics before deadlock cleanup while preserving the original timeout and interaction failures. Keep production logging and output-drain behavior unchanged. Related: openclaw#150244
Related: #150244
What Problem This Solves
CLI process tests can hit their deadlock guard after printing guidance, leaving no child-resource evidence to explain the stall. This is the maintainer-directed diagnostic follow-up to the hosted failure.
User Impact
There is no production behavior change. Maintainers get the child’s active resource/handle types, active request types, and bounded pending-promise counts in the next timeout failure. The underlying intermittent hang remains unexplained.
Why This Change Was Made
The shared test harness preloads a Node-only diagnostic signal handler and waits for its readiness acknowledgement before signaling it. A timeout remains a failure at the original deadline; a separate 200 ms diagnostic window precedes SIGKILL and pipe cleanup. An unresponsive child still receives bounded cleanup, and cleanup errors cannot replace the first failure. The diagnostic dump is retained separately from the stderr tail so later noisy output cannot hide it. Windows and Bun keep the existing termination path without this POSIX Node preload.
The production owner check found no metadata await blocking this error exit.
logger-file-transport.ts:74,229awaitsstatonly in the background flush;one-shot-output.ts:8,16independently schedules exit with a bounded stream drain. The synchronous buffered-log rescue atlogger-file-transport.ts:332,404remains unchanged.Evidence
"Timeout":1. It passes with the diagnostic preload, including when later stderr exceeds the output-tail limit.process.exit3–14 ms after guidance, with JavaScript exit handlers returning within 4–15 ms. The original hosted log has no guidance timestamp or handle dump.node scripts/check-changed.mjs: passed, including core test typechecking, all selected guards, and type-aware lint. Fresh pre-commit Codex autoreview: scoped-clean at P1. The requested--mode branch --base origin/main --max-priority P1review is also scoped-clean, with no findings.Production LOC delta: 0. Tests and test support: +244 / -61 (net +183), across three files.
Representative new guard failure excerpt:
Original-stall candidates and owner evidence
References below describe the investigated source at
387da5edaa9d6c6cfcfc15e167fe2e46d8647d86. These test, command, and exit owners match the failing PR head; the wider source trees differ.src/cli/one-shot-output.ts:8,12,16; reachable, with a five-second unreferenced fallback.src/logging/logger-file-transport.ts:74,322,332,404; reachable. Successful-run traces identify the pending request as loggerfs.promises.stat; it did not prevent exit.src/gateway/call.ts:1238rejects missing credentials before client creation at:954; normal settlement clears the timer and stops the client at:897,922.src/gateway/credentials-secret-inputs.ts:139requires a configured SecretRef; this fixture has none. Exec ownership issrc/secrets/resolve.ts:495.src/cli/devices-cli.runtime.ts:97selects read-only;src/state/openclaw-state-db-readonly.ts:369returns for the absent database. Coordinator retention atsrc/infra/sqlite-coordinator.ts:222,239is unreferenced.src/cli/progress.ts:130takes the no-op path for piped stderr.src/cli/gateway-backed-exit.process.test-support.ts:124,134disables both respawn paths for this fixture.src/cli/runtime-cleanup.ts:34,43; cleanup unwinds beforesrc/entry.ts:336prints guidance.node-sqlite.mjs:75,103,123; startup awaits the worker’s exit before admitting the CLI.No production cleanup divergence was found. The prior experiment selected the one failing test rather than replaying all 42 in original order, and instrumentation can affect scheduling.