openclaw - 💡(How to fix) Fix Gateway receives SIGTERM ~4 seconds after startup, causing frequent restart loop [1 comments, 1 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#56192Fetched 2026-04-08 01:43:50
View on GitHub
Comments
1
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
commented ×1

Error Message

Gateway starts, all connections established:

2026-03-28T12:50:52.160+08:00 [INFO] feishu[default]: WebSocket client started 2026-03-28T12:50:52.169+08:00 [INFO] feishu[dagongren]: WebSocket client started 2026-03-28T12:50:52.176+08:00 [INFO] feishu[shenghuodazi]: WebSocket client started 2026-03-28T12:50:52.665+08:00 [INFO] bonjour: advertised gateway fqdn=鲜橙的Mac mini (OpenClaw)._openclaw-gw._tcp.local. host=openclaw.local. port=18789 state=announcing

4 seconds later — SIGTERM with no preceding error:

2026-03-28T12:50:56.540+08:00 [INFO] {"subsystem":"gateway"} signal SIGTERM received 2026-03-28T12:50:56.543+08:00 [INFO] {"subsystem":"gateway"} received SIGTERM; shutting down

Code Example

# Gateway starts, all connections established:
2026-03-28T12:50:52.160+08:00 [INFO] feishu[default]: WebSocket client started
2026-03-28T12:50:52.169+08:00 [INFO] feishu[dagongren]: WebSocket client started
2026-03-28T12:50:52.176+08:00 [INFO] feishu[shenghuodazi]: WebSocket client started
2026-03-28T12:50:52.665+08:00 [INFO] bonjour: advertised gateway fqdn=鲜橙的Mac mini (OpenClaw)._openclaw-gw._tcp.local. host=openclaw.local. port=18789 state=announcing

# 4 seconds later — SIGTERM with no preceding error:
2026-03-28T12:50:56.540+08:00 [INFO] {"subsystem":"gateway"} signal SIGTERM received
2026-03-28T12:50:56.543+08:00 [INFO] {"subsystem":"gateway"} received SIGTERM; shutting down
RAW_BUFFERClick to expand / collapse

Bug Description

Gateway process receives SIGTERM and shuts down approximately 4 seconds after startup completes (all feishu WebSocket connections established + bonjour advertisement finished). Launchd KeepAlive then restarts it, creating a restart loop.

Environment

  • Version: 2026.3.24
  • Platform: macOS (Darwin 25.3.0, arm64)
  • Install method: Homebrew
  • Service: LaunchAgent (ai.openclaw.gateway.plist)
  • Node: v25.8.1

Steps to Reproduce

  1. Start gateway via LaunchAgent (`launchctl load`)
  2. Wait for all feishu accounts to connect WebSocket and bonjour to advertise
  3. After ~4 seconds, gateway receives SIGTERM and shuts down cleanly
  4. Launchd immediately restarts it (KeepAlive=true)
  5. Loop repeats

Gateway Status Output

``` Service: LaunchAgent (loaded) Runtime: running (pid XXXXX, state active) Gateway: bind=loopback (127.0.0.1), port=18789 RPC probe: ok Listening: 127.0.0.1:18789 ```

Relevant Log Excerpt

# Gateway starts, all connections established:
2026-03-28T12:50:52.160+08:00 [INFO] feishu[default]: WebSocket client started
2026-03-28T12:50:52.169+08:00 [INFO] feishu[dagongren]: WebSocket client started
2026-03-28T12:50:52.176+08:00 [INFO] feishu[shenghuodazi]: WebSocket client started
2026-03-28T12:50:52.665+08:00 [INFO] bonjour: advertised gateway fqdn=鲜橙的Mac mini (OpenClaw)._openclaw-gw._tcp.local. host=openclaw.local. port=18789 state=announcing

# 4 seconds later — SIGTERM with no preceding error:
2026-03-28T12:50:56.540+08:00 [INFO] {"subsystem":"gateway"} signal SIGTERM received
2026-03-28T12:50:56.543+08:00 [INFO] {"subsystem":"gateway"} received SIGTERM; shutting down

Note: No "restart scheduled" log line appears before SIGTERM — this is an external SIGTERM being received, not gateway-initiated restart.

Things Already Ruled Out

  • launchd ThrottleInterval: Previously set to 1s, now 60s — makes no difference
  • OOM kill: No evidence in system logs
  • External cron/job: No other jobs targeting the gateway process
  • Stale port processes: Port 18789 is clean before each restart
  • Config auto-reload: No config changes coincide with restarts

Timing Analysis

Across multiple restart cycles:

  • Startup → SIGTERM: consistently ~4 seconds after bonjour advertise
  • SIGTERM → Restart (by launchd): ~1-2 seconds
  • New instance starts and the cycle repeats

Questions /猜测

Could this be related to the feishu WS reconnection logic, specifically a channel health monitor that triggers a restart when connections are "too fresh"? Or possibly a startup timeout in the restart-sentinel module that fires incorrectly?


Happy to provide additional logs or run with debug flags if helpful.

extent analysis

Fix Plan

To address the restart loop issue, we'll focus on the potential causes related to the feishu WebSocket reconnection logic and the startup timeout in the restart-sentinel module. Here are the steps:

  • Step 1: Modify the feishu WebSocket reconnection logic
    • Introduce a delay before considering the connections "established" to prevent premature restarts.
    • Example code (Node.js):

const ws = require('ws');

// ...

// Delay the "established" state by 10 seconds setTimeout(() => { console.log('Feishu WebSocket connections established'); // Proceed with bonjour advertisement }, 10000);

* **Step 2: Adjust the startup timeout in the restart-sentinel module**
  + Increase the timeout value to accommodate the delayed "established" state.
  + Example code (Node.js):
    ```javascript
const restartSentinel = require('restart-sentinel');

// ...

// Increase the startup timeout to 15 seconds
restartSentinel.setTimeout(15000);
  • Step 3: Verify the changes
    • Restart the gateway service and monitor the logs for the restart loop.

Verification

To verify that the fix worked, check the gateway logs for the following:

  • The restart loop should be broken, and the gateway should remain running without receiving SIGTERM.
  • The feishu WebSocket connections should be established successfully, and the bonjour advertisement should complete without triggering a restart.

Extra Tips

  • Monitor the system logs for any other potential issues that might be contributing to the restart loop.
  • Consider adding additional logging or debugging statements to help identify the root cause of the issue.
  • If the issue persists, try increasing the delay or timeout values to further troubleshoot the problem.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING