Skip to content

[Bug]: exec spawn UNKNOWN after gateway restart — child_process pool not rebuilt #89332

Closed as not planned

Description

@q1387154-spec

Bug: exec tool returns spawn UNKNOWN after gateway restart

What happened

After a gateway restart (config.patch triggers restart), the exec tool occasionally fails with spawn UNKNOWN error. This breaks all shell command execution until the pool recovers or another restart happens.

Environment

  • OpenClaw: 2026.5.28 (e932160)
  • OS: Windows 10.0.26200 (x64)
  • Node: v24.16.0

Reproduction

  1. Run a config.patch that triggers a gateway restart (e.g., model fallback change)
  2. Immediately after restart, invoke the exec tool
  3. Observe spawn UNKNOWN error instead of command execution

This also manifests as gh CLI commands failing with the same error, confirming it is a general exec tool issue, not specific to one command.

Root cause analysis

The gateway restart process drains active tasks and attempts in-process restart on Windows (detached respawn is disabled on win32 unless schtasks is available). The child_process pool that backs the exec tool appears to not be fully rebuilt after the in-process restart cycle completes. This leaves exec in a broken state.

Related: the drain race condition during restart (markRestartAbortedMainSessions exists in source) may leave the process pool in an inconsistent state.

Impact

  • Severity: P0 — all exec-dependent features broken (code execution, shell scripts, CLI tools, Housekeeping cron jobs)
  • Frequency: After each gateway restart on Windows
  • Affected: Windows primarily (in-process restart path); may affect other platforms with similar restart paths

Activity

  1. clawsweeper commented on Jun 2, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 5:13 AM ET / 09:13 UTC.

    Summary
    Keep open: current main and the latest release do not prove the Windows post-restart spawn UNKNOWN symptom is fixed, while source contradicts the reported child-process-pool root cause and no live Windows current-main reproduction is available.

    Reproducibility: no. high-confidence current-main reproduction yet. Source shows a non-EBADF spawn error such as UNKNOWN would propagate, but this review did not establish that Gateway restart triggers it on Windows current main.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.

    Next step
    Manual review should collect live Windows current-main evidence before repair because the source contradicts the stated pool root cause and no canonical fix owns this exact symptom.

    Review details

    Best possible solution:

    Capture live Windows current-main proof for a restart-required config.patch followed by immediate exec, then fix the proven layer with focused UNKNOWN spawn hardening or restart lifecycle repair plus regression coverage.

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

    No high-confidence current-main reproduction yet. Source shows a non-EBADF spawn error such as UNKNOWN would propagate, but this review did not establish that Gateway restart triggers it on Windows current main.

    Is this the best way to solve the issue?

    Unclear. Rebuilding a child_process pool is not the best fix because current exec creates supervisor runs per spawn; the right repair depends on whether live evidence points to transient Windows spawn failure, handle exhaustion, or restart lifecycle state.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • No live Windows current-main config.patch restart followed by immediate exec has been captured, so the trigger remains unconfirmed.
    • The source contradicts the child-process-pool theory; a fix based on rebuilding a pool would likely target the wrong layer.
    • Adjacent restart/process lifecycle reports overlap, but none is a safe canonical owner for this exact spawn UNKNOWN symptom.

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

    Label changes

    Label changes:

    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.
    • remove clawsweeper:needs-info: Current issue advisory state no longer selects this label.
    • remove issue-rating: 🦪 silver shellfish: Current issue advisory state no longer selects this label.

    Label justifications:

    • P1: The report describes exec-dependent agent and maintenance workflows becoming unusable after Gateway restart on Windows.
    • impact:crash-loop: The reported failure is a process-level availability loss where shell execution stays broken until recovery or another restart.
    Evidence reviewed

    What I checked:

    • issue_discussion: Live issue context contains concrete Windows 2026.5.28 steps and a maintainer-side comment saying the pool-rebuild theory does not match current source, but no redacted logs or live Windows current-main proof were added.
    • current_exec_spawn_path: Current main's exec runtime gets the process supervisor per run and calls supervisor.spawn for the PTY or child invocation, so the central path does not expose a reusable child_process pool to rebuild after restart. (src/agents/bash-tools.exec-runtime.ts:612, e9b694ef9cd8)
    • current_supervisor_model: Current main creates a fresh run record inside spawn, and reconcileOrphans remains a no-op documenting in-memory ownership only; this supports the existing source-review concern that restart lifecycle may matter, but not a pool rebuild. (src/process/supervisor/supervisor.ts:123, e9b694ef9cd8)
    • spawn_unknown_would_still_propagate: Current main retries only EBADF by default and throws non-retry spawn errors, so a Node UNKNOWN spawn error would still surface if Windows emits it. (src/process/spawn-utils.ts:25, e9b694ef9cd8)
    • restart_reset_path: The in-process restart iteration resets command lanes and runtime restart state, which reduces the stale-lane theory but does not prove immediate post-restart Windows spawns cannot fail. (src/cli/gateway-cli/run-loop.ts:795, e9b694ef9cd8)
    • latest_release_behavior: The latest release v2026.6.9 has the same exec supervisor call shape, no-op orphan reconciliation, and EBADF-only spawn retry default, so this exact symptom is not proven fixed in the shipped release either. (src/process/spawn-utils.ts:25, c645ec4555c0)

    Likely related people:

    • vincentkoc: Recent current-main and release history touched Windows process cleanup and the current spawn/supervisor files used in this review. (role: recent area contributor; confidence: high; commits: e9b694ef9cd8, 273eb888749f, c645ec4555c0; files: src/process/spawn-utils.ts, src/process/supervisor/supervisor.ts, src/process/supervisor/adapters/child.ts)
    • steipete: Authored the earlier exec spawn fallback hardening and has substantial later history around exec and restart lifecycle fixes. (role: exec spawn and restart-area contributor; confidence: high; commits: c6cdbb630c92, 680eff63fbf8, c397a02c9ad5; files: src/process/spawn-utils.ts, src/cli/gateway-cli/run-loop.ts, src/process/command-queue.ts)
    • onutc: Introduced the process supervisor refactor that routes exec and PTY runs through the current supervisor model, including the no-op orphan reconciliation surface adjacent to this report. (role: process supervisor introducer; confidence: high; commits: cd44a0d01e9f; files: src/process/supervisor/supervisor.ts, src/process/supervisor/adapters/child.ts, src/agents/bash-tools.exec-runtime.ts)
    • obviyus: Authored Windows Scheduled Task restart support and Windows supervisor wait fixes near the reported platform and lifecycle surface. (role: Windows restart and supervisor contributor; confidence: medium; commits: 05c240fad6fe, 4b6b1a3ed358; files: src/infra/process-respawn.ts, src/infra/windows-task-restart.ts, src/process/supervisor/adapters/child.ts)
    • mjamiv: Authored the merged change that keeps unmanaged ordinary restarts in-process, which is directly adjacent to Windows restart behavior in this issue. (role: current restart fallback contributor; confidence: medium; commits: c93d6d8daa37; files: src/infra/process-respawn.ts, src/infra/process-respawn.test.ts)
    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.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    on Jun 2, 2026
  3. yetval commented on Jun 6, 2026

    @yetval
    Contributor

    Thanks for the detailed write up and root cause analysis on this one.

    I traced the full restart and exec path on current main and the described mechanism does not seem to hold, since there is no child_process pool to rebuild and the process supervisor is stateless between spawns and builds a fresh child on every call. The in process SIGUSR1 restart resets the command lanes and the task registry but never changes the working directory or the environment, so it should not leave exec in a broken state, and spawn UNKNOWN on Windows is an OS level error from child_process.spawn that is usually environmental such as handle exhaustion. Given that the stated cause looks contradicted by the source and there is no live Windows reproduction this may not be reproducible as written, so a redacted log or a recording would really help if anyone can capture it again. Separately, hardening the Windows spawn path with a retry for transient UNKNOWN errors seems reasonable and might be worth its own issue.

  4. added
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    and removed
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    on Jun 15, 2026
  5. openclaw-barnacle commented on Jul 6, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  6. openclaw-barnacle commented on Jul 14, 2026

    @openclaw-barnacle

    Closing due to inactivity.
    If this is still an issue, please retry on the latest OpenClaw release and share updated details.
    If you are absolutely sure it still happens on the latest release, open a new issue with fresh steps to reproduce.

  7. locked as resolved and limited conversation to collaborators on Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions