Skip to content

fix(status): bound systemd service probes so status cannot hang on a wedged systemctl (#84698) - #94149

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
ZengWen-DT:fix/84698-status-systemctl-timeout
Jul 1, 2026
Merged

vincentkoc merged 3 commits into
openclaw:mainfrom
ZengWen-DT:fix/84698-status-systemctl-timeout

Conversation

@ZengWen-DT

Copy link
Copy Markdown
Contributor

Summary

  • Fixes openclaw status hanging until an external timeout (exit 124) when the systemd user/system manager is wedged: the service-summary probe spawned systemctl with no deadline, so --timeout was advertised but never applied to it.
  • Threads the status read deadline from resolveStatusServiceSummaries → readGatewayServiceState → the systemd read helpers → execSystemctl/execSystemctlUser, and passes it to execFile as timeout + killSignal: SIGKILL so a stuck systemctl child is killed and the command fails soft to a degraded ("unknown") service row instead of hanging. A default 5s bound applies when status runs without --timeout.
  • Leaves control/install paths (systemctl start/stop/enable/...) unchanged — they pass no timeout, so their behavior is identical to today.

Linked context

Closes #84698

Real behavior proof

  • Behavior or issue addressed: openclaw status (and status --all) hangs indefinitely / exits 124 when systemctl does not return, ignoring --timeout.
  • Real environment tested: Linux (WSL2, Ubuntu kernel), real systemctl replaced on PATH by a wedged double (#!/usr/bin/env bash … sleep 120) that simulates a stuck systemd socket. Production code path exercised: resolveStatusServiceSummaries → readGatewayServiceState → readSystemdServiceRuntime/isSystemdServiceEnabled → execSystemctl. This spawns a real child process (not a mock).
  • Root cause / premise evidence: on current main, resolveStatusRuntimeDetails awaits resolveStatusServiceSummaries() with no timeout argument, and execSystemctl calls execFileUtf8("systemctl", …) with no timeout, so a non-returning systemctl blocks the event loop forever. node:child_process execFile's timeout option kills the child on expiry (verified directly: callback fired at 1506ms with killed=true signal=SIGKILL), which lets the command settle.
  • Before evidence (bug reproduced on main): driving the production resolveStatusServiceSummaries(2000) against the wedged systemctl double on pristine upstream/main, with an 8s watchdog:
{ "kind": "HUNG_8s", "elapsedMs": 8003, "rows": null }
systemctl invocations seen by the double:
  21:04:07 systemctl --user status
  21:04:07 systemctl --user status   (gateway + node probes — neither ever returns)
  • Exact steps or command run after this patch: drove the production resolveStatusServiceSummaries(2000) on this branch against the same wedged systemctl double on PATH, capturing the returned rows and the double's invocation log.
  • Evidence after fix: the probe now returns degraded rows well within the bound, and the double's status calls are killed at the 2s deadline before the show calls run:
{
  "kind": "RETURNED",
  "elapsedMs": 4313,
  "rows": ["systemd user: disabled", "systemd user: disabled"]
}
systemctl invocations seen by the double:
  21:03:33 systemctl --user status   (killed at 2s)
  21:03:35 systemctl --user show openclaw-gateway.service ...
  21:03:35 systemctl --user show openclaw-node.service ...
  • Observed result after fix: openclaw status no longer hangs on a wedged systemctl; it returns a degraded service row and respects the configured deadline (worst case ≈ 2× the deadline per service for the sequential status+show probes, parallelized across gateway/node).
  • What was not tested: the full openclaw status CLI end-to-end on this machine — on my checkout the command stalls earlier, before the service-summary stage (no gateway running), on clean main too, so the box cannot exercise the full CLI hang. The defect and fix were therefore proven at the owning component with a real wedged systemctl subprocess. launchd (macOS) and Windows scheduled-task probes are left unchanged here; the new timeoutMs/GatewayServiceReadOptions plumbing makes wiring them later trivial, and those are tracked by separate open reports.
  • Proof limitations or environment constraints: the wedged systemctl is a deliberately hanging real binary on PATH, not the production systemd daemon; this matches the reported failure mode (systemd socket wedged before reply).

Tests and validation

  • git diff --check
  • node scripts/run-vitest.mjs src/daemon/systemd.test.ts (92 passed, incl. 2 new regressions)
  • node scripts/run-vitest.mjs src/commands/status-runtime-shared.test.ts src/commands/status.daemon.test.ts
  • pnpm tsgo:core and pnpm tsgo:core:test (clean); oxfmt --check and oxlint clean on the changed files.

Risk checklist

Did user-visible behavior change? Yes — openclaw status now returns a degraded service row under a wedged service manager instead of hanging; happy-path output is unchanged.

Did config, environment, or migration behavior change? No

Did security, auth, secrets, network, or tool execution behavior change? No

Highest-risk area: the shared readGatewayServiceState / GatewayService.readRuntime signature, used by gateway and node services.

How is that risk mitigated? The new timeoutMs/opts are optional; only status read paths pass them, so control/install flows and other callers keep their current (unbounded) behavior, and typecheck confirms all call sites.

Current review state: maintainer review and CI.

AI-assisted (Claude). Proof above was run manually.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: S proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 17, 2026
@clawsweeper

clawsweeper Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 1, 2026, 9:50 AM ET / 13:50 UTC.

Summary
The branch threads the status timeout through service-summary reads into Linux systemd probes, adds optional service-read timeout plumbing, and adds daemon regression tests for kill-backed systemctl timeouts.

PR surface: Source +41, Tests +27. Total +68 across 10 files.

Reproducibility: yes. for the component path: current main reaches unbounded systemctl calls from status service summaries, and the PR body provides before/after live output against a wedged systemctl double. I did not run a full CLI reproduction in this read-only review.

Review metrics: 1 noteworthy metric.

  • Status service-probe default: 1 added: 5s default when no explicit status timeout is supplied. This default is the compatibility tradeoff maintainers should notice because it can turn very slow service-manager reads into degraded status rows.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #84698
Summary: This PR is the candidate fix for the canonical Linux openclaw status/systemctl hang; Windows, macOS, and Docker-probe items overlap only by status-hang theme or adjacent subprocess paths.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] The added 5s default service-probe deadline can change existing Linux status behavior for very slow but eventually returning systemctl calls from waiting indefinitely to showing a degraded service row.
  • [P1] The PR proves the owning Linux service-summary/systemd component path, but not a full end-to-end openclaw status CLI run; macOS launchd and Windows schtasks status hangs remain separate work.

Maintainer options:

  1. Accept The Focused Linux Bound (recommended)
    Land the PR after maintainer review, accepting that very slow systemd reads may now degrade to unknown instead of waiting indefinitely.
  2. Tune The Default Before Merge
    Adjust the default service-probe deadline if maintainers want a different slow-systemd tradeoff while preserving the timeout-threading shape.
  3. Pause For Full CLI Proof
    Hold the PR if maintainers require full Linux openclaw status output from a setup that reaches service summaries before accepting component proof.

Next step before merge

  • No automated repair lane is needed because there is no discrete patch defect; maintainers should decide whether to accept or tune the new default-bound behavior before merge.

Security
Cleared: No security or supply-chain concern found; the diff adds no dependencies, workflows, permissions, or new command sources and only bounds existing read-only systemctl probes.

Review details

Best possible solution:

Land this focused Linux systemd timeout fix after maintainers accept or tune the 5s default-bound tradeoff, while keeping macOS and Windows service-manager timeout work separate.

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

Yes for the component path: current main reaches unbounded systemctl calls from status service summaries, and the PR body provides before/after live output against a wedged systemctl double. I did not run a full CLI reproduction in this read-only review.

Is this the best way to solve the issue?

Yes for the linked Linux regression: forwarding the existing status deadline into read-only systemd probes is the narrow maintainable fix. The default 5s fallback is the remaining maintainer tradeoff, not a code-path defect.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: The PR fixes a concrete diagnostic CLI hang with limited blast radius and no data-loss or security scope.
  • merge-risk: 🚨 compatibility: The new default service-probe deadline can change status output for existing Linux users whose systemctl is very slow but eventually returns.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes before/after live output from the production service-summary path using a real wedged systemctl double; full CLI proof is absent but the changed component behavior is directly shown.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes before/after live output from the production service-summary path using a real wedged systemctl double; full CLI proof is absent but the changed component behavior is directly shown.
Evidence reviewed

PR surface:

Source +41, Tests +27. Total +68 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 8 65 24 +41
Tests 2 27 0 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 92 24 +68

What I checked:

  • Repository policy read: Root AGENTS.md was read fully and its review-depth, proof, and compatibility guidance applies to this PR. (AGENTS.md:1, f936c6b49504)
  • Current main status timeout gap: Current main receives timeoutMs in resolveStatusRuntimeDetails but still calls resolveStatusServiceSummaries without passing it. (src/commands/status-runtime-shared.ts:293, f936c6b49504)
  • Current main systemd wrapper is unbounded: Current main execSystemctl passes only env to execFileUtf8, so readSystemdServiceRuntime and isSystemdServiceEnabled can wait indefinitely on a wedged systemctl child. (src/daemon/systemd.ts:566, f936c6b49504)
  • Latest release still has the gap: Tag v2026.6.11 still calls resolveStatusServiceSummaries without a deadline and has no timeout/killSignal in execSystemctl. (src/commands/status-runtime-shared.ts:219, e085fa1a3ffd)
  • Patch shape: The PR diff forwards timeoutMs through status-all/runtime details, daemon summary, readGatewayServiceState, node-service delegation, and Linux systemd read helpers, while control/install paths remain unbounded. (src/daemon/systemd.ts:546, ca23b7f5d8f6)
  • Dependency behavior proof: A direct Node child_process.execFile probe killed a non-returning child with SIGKILL at the configured timeout, matching the PR's execFile timeout/killSignal contract.

Likely related people:

  • vincentkoc: Recent commits changed the same Linux systemd status and service-scope behavior that this PR bounds. (role: recent systemd/status contributor; confidence: high; commits: 64785823d093, 97d35f4c575b; files: src/daemon/systemd.ts)
  • steipete: History shows repeated work on status runtime helpers and the shared daemon service-state flow that this PR threads through. (role: status/service architecture contributor; confidence: high; commits: f0b3c4164f61, 258a214bcbff, 2761e8cc3b1a; files: src/commands/status-runtime-shared.ts, src/daemon/service.ts, src/daemon/systemd.ts)
  • yetval: Recent Linux system-scope detection work touched readSystemdServiceRuntime and isSystemdServiceEnabled, the same read path now being bounded. (role: adjacent systemd contributor; confidence: medium; commits: b988e2f92b0c; files: src/daemon/systemd.ts)
  • TurboTheTurtle: Recent commits changed explicit systemd unit preservation and status JSON behavior near the service-state/status boundary. (role: recent service-state/status contributor; confidence: medium; commits: 3fea2196923b, f3e61580bdc1; files: src/daemon/service.ts, src/commands/status-runtime-shared.ts)
  • masatohoshino: The most recent live history for src/daemon/systemd.ts includes systemd start-limit status handling adjacent to the same runtime inspection surface. (role: recent systemd area contributor; confidence: medium; commits: 76f9b6d83758; files: src/daemon/systemd.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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P2 Normal backlog priority with limited blast radius. labels Jun 19, 2026
@ZengWen-DT
ZengWen-DT force-pushed the fix/84698-status-systemctl-timeout branch from 4cdab80 to 4f30544 Compare June 20, 2026 14:58
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 21, 2026
@ZengWen-DT
ZengWen-DT force-pushed the fix/84698-status-systemctl-timeout branch from 4f30544 to e0f4df9 Compare June 23, 2026 12:52
)

Keep both the openclaw#84698 timeout regression tests and the crash-loop
supervision counter test added on main.

Co-authored-by: Cursor <[email protected]>
@vincentkoc vincentkoc self-assigned this Jul 1, 2026

@vincentkoc vincentkoc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the status/systemd timeout path and the tradeoff. Bounded degraded status output is the right behavior for a diagnostic command; control/install paths remain unbounded.

@vincentkoc
vincentkoc merged commit b6ad306 into openclaw:main Jul 1, 2026
95 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 2, 2026
…wedged systemctl (openclaw#84698) (openclaw#94149)

* fix(status): bound systemd service probes so status cannot hang on a wedged systemctl (openclaw#84698)

* test(daemon): assert readRuntime receives the threaded status timeout opts (openclaw#84698)

---------

Co-authored-by: Cursor <[email protected]>
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Jul 15, 2026
…wedged systemctl (openclaw#84698) (openclaw#94149)

* fix(status): bound systemd service probes so status cannot hang on a wedged systemctl (openclaw#84698)

* test(daemon): assert readRuntime receives the threaded status timeout opts (openclaw#84698)

---------

Co-authored-by: Cursor <[email protected]>
(cherry picked from commit b6ad306)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

[Bug]: openclaw status hangs and times out — regression from 2026.5.7

2 participants