openclaw - ✅(Solved) Fix [Bug]: Gateway repeatedly restarts under launchd after crash, making it difficult to debug [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73673Fetched 2026-04-29 06:16:36
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×2commented ×1cross-referenced ×1

When running under launchd, gateway crashes cause immediate restarts, leading to continuous restart loops and making debugging difficult.

Root Cause

Affected: macOS users running via launchd Severity: Medium–High (difficult to debug failures) Frequency: Always when startup fails Consequence: Logs scroll rapidly and root cause is hard to inspect

Fix Action

Fixed

PR fix notes

PR #73849: fix(daemon): use KeepAlive SuccessfulExit=false to prevent launchd crash-loop

Description (problem / solution / changelog)

Fixes #73673

Problem

The macOS LaunchAgent plist uses KeepAlive=true, which restarts the gateway after ANY exit (including clean exits with code 0). This creates a crash-loop where:

  1. Gateway exits (clean or crash)
  2. launchd immediately restarts it
  3. If the root cause was a crash, it crashes again
  4. Repeat indefinitely, making debugging extremely difficult

Solution

Change KeepAlive=true to KeepAlive with SuccessfulExit=false:

  • Gateway only restarts on crash (non-zero exit code)
  • Clean exits are respected (gateway stays stopped for debugging)
  • ThrottleInterval=1 still applies to crash restarts

Changes

  • src/daemon/launchd-plist.ts: Updated plist template to use KeepAlive<dict>SuccessfulExit<false/></dict>
  • src/daemon/launchd.test.ts: Updated test to expect new KeepAlive format
  • src/daemon/service-audit.ts: Updated audit check to recognize both KeepAlive forms

Changed files

  • src/agents/sandbox/browser.ts (modified, +11/-0)
  • src/agents/sandbox/docker.ts (modified, +42/-4)
  • src/commands/doctor-sandbox.ts (modified, +5/-0)
  • src/daemon/launchd-plist.ts (modified, +1/-1)
  • src/daemon/launchd.test.ts (modified, +4/-3)
  • src/daemon/service-audit.ts (modified, +4/-2)

Code Example

Repeated restart behavior observed:

process exited → restarting...
(repeats continuously)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When running under launchd, gateway crashes cause immediate restarts, leading to continuous restart loops and making debugging difficult.

Steps to reproduce

  1. Configure OpenClaw to run via launchd (LaunchAgent)

  2. Introduce a startup failure (e.g. invalid hostname)

  3. Start the service via launchd

  4. Observe repeated restarts

Expected behavior

System should allow users to observe and debug startup failures without continuous restarts.

Actual behavior

Gateway restarts immediately after each crash:

process exited → restarting... process exited → restarting...

This repeats continuously without pause.

OpenClaw version

2026.4.24

Operating system

macOS 15.4

Install method

launchd (LaunchAgent)

Model

NOT_RELEVANT

Provider / routing chain

NOT_RELEVANT

Additional provider/model setup details

NOT_RELEVANT

Logs, screenshots, and evidence

Repeated restart behavior observed:

process exited → restarting...
(repeats continuously)

Impact and severity

Affected: macOS users running via launchd Severity: Medium–High (difficult to debug failures) Frequency: Always when startup fails Consequence: Logs scroll rapidly and root cause is hard to inspect

Additional information

Service must be manually stopped using launchctl unload to inspect failures.

extent analysis

TL;DR

Configure launchd to introduce a delay between restarts or implement a retry limit to prevent continuous restart loops.

Guidance

  • Investigate launchd configuration options to add a delay between restarts, allowing for easier debugging of startup failures.
  • Consider implementing a retry limit in the launchd configuration to prevent infinite restart loops.
  • Review the launchd documentation to understand how to customize the restart policy for the OpenClaw service.
  • Use launchctl commands to manually manage the service and inspect failures, as automatic restarts can make debugging challenging.

Example

No specific code example is provided, as the solution involves configuring launchd rather than modifying OpenClaw code.

Notes

The exact launchd configuration options may vary depending on the version of macOS and launchd. It is essential to consult the official launchd documentation for the specific configuration options available.

Recommendation

Apply a workaround by configuring launchd to introduce a delay between restarts or implement a retry limit, as this will allow for easier debugging of startup failures without requiring an upgrade to a potentially non-existent fixed version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

System should allow users to observe and debug startup failures without continuous restarts.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING