Skip to content

Updater submits manual-update job via launchctl submit → KeepAlive defaults true → infinite update loop that repeatedly stops the gateway #88736

Closed

Description

@deonkretch

Summary

On macOS, openclaw update schedules its out-of-process update job using launchctl submit. launchctl submit creates the job with KeepAlive = true by default, so the update runner (run-openclaw-update.zsh) is relaunched immediately every time it exits. Each iteration runs openclaw update, whose first action is "Stopping managed gateway service before package update" — so the managed gateway is killed roughly once per minute and never stays up. The package update itself succeeds on the first pass; the loop continues forever afterward with availability.available = false.

Net user-visible symptom: after updating, the gateway won't stay up.

Environment

  • OpenClaw 2026.5.28 (commit e932160); first observed after auto-update 2026.5.26 → 2026.5.28
  • Install: global package at /opt/homebrew/lib/node_modules/openclaw (pnpm)
  • node v25.6.1
  • macOS 26.4 (arm64)

Impact

  • Managed gateway (ai.openclaw.gateway) is force-stopped ~1×/minute indefinitely → all agents/channels (Discord, Telegram, cron) keep dropping.
  • Two jobs were submitted ~1s apart (ai.openclaw.manual-update.<epoch>), so the gateway was being stopped by two concurrent loops.
  • ~/.openclaw/work/update-logs/openclaw-update-*.log grew to ~2 MB / 80+ repeated == START / == UPDATE / == DOCTOR cycles in ~80 min.
  • ~/.openclaw/logs/gateway-restart.log fills with Could not find service "ai.openclaw.gateway" in domain for user gui: 501 as the loop races with itself (kickstart attempted against a service that a concurrent iteration has just booted out).

Root cause

The submitted launchd jobs are KeepAlive. Confirmed via:

$ launchctl print gui/501/ai.openclaw.manual-update.<epoch>
    path = (submitted by launchctl[...])
    program = /Users/<user>/.openclaw/work/update-logs/run-openclaw-update.zsh
    properties = keepalive | inferred program

path = (submitted by launchctl ...) + properties = keepalive = a launchctl submit job using the default unconditional KeepAlive. run-openclaw-update.zsh exits cleanly (DOCTOR_EXIT 0) each cycle, and launchd relaunches it in the same second:

== END   Sun May 31 19:49:38 SAST 2026 ==
== START Sun May 31 19:49:38 SAST 2026 ==

Steps to reproduce

  1. On macOS, trigger an update that uses the launchctl-submit path (e.g. auto-update or openclaw update).
  2. Observe a transient ai.openclaw.manual-update.<epoch> job appear: launchctl list | grep manual-update.
  3. launchctl print gui/$(id -u)/ai.openclaw.manual-update.<epoch> → properties = keepalive.
  4. Watch the gateway get stopped each cycle (gateway-restart.log / update log) and never stay up.

Expected

The update job runs once and exits. The gateway is stopped only for the actual package swap, then restarted and left running.

Suggested fix

launchctl submit is deprecated and defaults to unconditional KeepAlive — it's the wrong primitive for a run-once task. Options:

  1. Preferred: write a temporary LaunchAgent plist with KeepAlive = false (or omit it) and RunAtLoad = true, bootstrap it, and bootout it on completion — instead of launchctl submit.
  2. If staying with launchctl submit, the runner must remove its own job on exit (e.g. launchctl remove ai.openclaw.manual-update.<epoch> as the last step) so it can't be relaunched.
  3. Defensive: never submit a second update job while one is already registered (the two near-simultaneous submits doubled the damage).
  4. The "stop the gateway before update" step should be gated on an update actually being applied — when availability.available == false, the job should no-op instead of stopping the gateway.

Workaround (for affected users)

# tear down the runaway loop
for l in $(launchctl list | awk '/ai\.openclaw\.manual-update/ {print $3}'); do launchctl bootout gui/$(id -u)/$l; done
pkill -f run-openclaw-update.zsh; pkill -f openclaw-doctor
# the gateway is left booted out — reload it
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/ai.openclaw.gateway.plist
launchctl kickstart -k gui/$(id -u)/ai.openclaw.gateway

The submitted jobs are not persisted to disk, so they don't survive logout/reboot — but the next update re-triggers the loop until this is fixed.

Activity

  1. clawsweeper commented on May 31, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 31, 2026, 2:30 PM ET / 18:30 UTC.

    Summary
    Keep open: the reported macOS runaway updater loop is still plausible against current main because launchd updater cleanup only recognizes ai.openclaw.update.*, while the report shows ai.openclaw.manual-update.*; a repeated package update still stops the managed gateway before replacement.

    Reproducibility: yes. for the source-level failure boundary: current main only recognizes ai.openclaw.update.*, so a reported ai.openclaw.manual-update.<epoch> launchd label is ignored by cleanup. I did not run a live macOS launchd repro in this read-only review.

    Next step
    A focused repair can add compatibility handling and regression tests for the observed manual-update launchd labels, but the implementation should first verify no current producer remains hidden outside the searched source path.

    Review details

    Best possible solution:

    Recognize and disarm observed one-shot updater launchd labels such as ai.openclaw.manual-update.* before stopping the gateway, and surface them in doctor/status cleanup while preserving the existing package-refresh behavior unless maintainers choose a broader policy change.

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

    Yes for the source-level failure boundary: current main only recognizes ai.openclaw.update.*, so a reported ai.openclaw.manual-update.<epoch> launchd label is ignored by cleanup. I did not run a live macOS launchd repro in this read-only review.

    Is this the best way to solve the issue?

    Yes directionally: the narrow maintainable fix is to disarm the one-shot updater job before the package-update stop step and cover the manual-update label in tests. Changing the already-tested package refresh behavior when no newer version is available should be treated as separate policy work.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The exact producer of ai.openclaw.manual-update.* was not found in current source, so a fix should narrowly handle the observed updater labels without broadening cleanup to real gateway LaunchAgent labels.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 2fbddce88182.

    Label changes

    Label changes:

    • add P1: The report describes a current update path that can repeatedly stop the managed gateway and break real channel/agent workflows after update.
    • add impact:crash-loop: The affected launchd updater loop repeatedly stops the gateway, making the managed runtime unable to stay available.
    • add impact:message-loss: When the gateway repeatedly drops, connected channels such as Discord, Telegram, and cron can miss or interrupt message handling.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.

    Label justifications:

    • P1: The report describes a current update path that can repeatedly stop the managed gateway and break real channel/agent workflows after update.
    • impact:crash-loop: The affected launchd updater loop repeatedly stops the gateway, making the managed runtime unable to stay available.
    • impact:message-loss: When the gateway repeatedly drops, connected channels such as Discord, Telegram, and cron can miss or interrupt message handling.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/daemon/launchd.test.ts
    • node scripts/run-vitest.mjs src/commands/doctor-platform-notes.launchctl-env-overrides.test.ts
    • node scripts/run-vitest.mjs src/cli/daemon-cli/status.gather.test.ts src/cli/daemon-cli/status.print.test.ts
    • node scripts/run-vitest.mjs src/cli/update-cli.test.ts --runInBand

    What I checked:

    • Current updater labels exclude manual-update: Current main normalizes updater launchd labels only when they start with ai.openclaw.update., so the reported ai.openclaw.manual-update.<epoch> label would not be recognized. (src/daemon/launchd.ts:49, 2fbddce88182)
    • Stale launchd job sweep uses the same narrow prefix: The current stale updater job parser skips any launchctl list entry whose label does not start with the single update prefix, so status/doctor cleanup would not surface the reported manual-update job. (src/daemon/launchd.ts:304, 2fbddce88182)
    • Package updates still stop the managed service before replacement: For package updates, current main calls maybeStopManagedServiceBeforePackageUpdate before running the package manager update; inside that helper a running managed gateway is stopped before the install step. (src/cli/update-cli/update-command.ts:3308, 2fbddce88182)
    • Latest release has the same prefix behavior: The latest release tag resolves to e932160, and that release also only accepts ai.openclaw.update. in normalizeOpenClawUpdateLaunchdLabel. (src/daemon/launchd.ts:49, e93216080aa1)
    • Current tests cover update labels but not manual-update labels: The launchd tests assert stale updater parsing and disarming for ai.openclaw.update.2026.5.12, but there is no analogous coverage for the reported ai.openclaw.manual-update.* label. (src/daemon/launchd.test.ts:434, 2fbddce88182)
    • Exact submitted-job producer was not found in current source: A current-main exact-term search found no manual-update, run-openclaw-update, launchctl submit, or ai.openclaw.manual-update source occurrence, so the remaining repair should focus on compatibility cleanup for observed launchd jobs unless a producer is found during implementation. (2fbddce88182)

    Likely related people:

    • Peter Steinberger: Current blame for the managed update handoff, launchd updater cleanup, and package-update service stop paths points to commit 21dcf2d, and earlier history shows the core auto-updater was introduced in f442a35 by the same author. (role: recent area contributor; confidence: high; commits: 21dcf2dd994c, f442a3539f19; files: src/daemon/launchd.ts, src/cli/update-cli/update-command.ts, src/gateway/server-methods/update-managed-service-handoff.ts)
    • hclsys: The macOS update restart helper was recently hardened in commit 4a87030, credited to this contributor in the follow-up PR commit message, so they are relevant adjacent context for launchctl update behavior. (role: adjacent contributor; confidence: medium; commits: 4a870300ddc5, 089e038dfeb9; files: src/cli/update-cli/restart-helper.ts, src/cli/update-cli/restart-helper.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.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    on May 31, 2026
  3. locked as resolved and limited conversation to collaborators on Jun 3, 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:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions