You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] SafeGatewayPlugin: Unhandled exception on WebSocket close code 1005 crashes gateway (triggered by health-monitor stale-socket restart) #55554
When the health-monitor restarts a stale socket (e.g. [discord:default] health-monitor: restarting (reason: stale-socket)), the resulting WebSocket close triggers an unhandled exception in \SafeGatewayPlugin\ that kills the entire gateway process.
Version
OpenClaw \2026.3.24\ · Windows 10.0.19045 (x64) · Node 24.14.1
Steps to Reproduce
Gateway running with Discord channel enabled
Health-monitor detects a stale socket and triggers a restart
WebSocket closes with code 1005
Gateway process crashes with uncaught exception
Error
\
2026-03-27T03:51:01.274Z info gateway/health-monitor [discord:default] health-monitor: restarting (reason: stale-socket)
2026-03-27T03:51:01.377Z error [openclaw] Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
at SafeGatewayPlugin.handleReconnectionAttempt (provider-CAlWEl41.js:3318:47)
at SafeGatewayPlugin.handleClose (provider-CAlWEl41.js:3364:8)
at WebSocket. (provider-CAlWEl41.js:3307:9)
at WebSocket.emit (node:events:508:28)
at WebSocket.emitClose (ws/lib/websocket.js:273:10)
at TLSSocket.socketOnClose (ws/lib/websocket.js:1346:15)
\\
Impact
Full gateway crash (~54s downtime before watchdog recovery)
All channels (Telegram, Discord) go offline until watchdog restarts the process
Recurring — happens every ~35 minutes since updating to 2026.3.24
Expected Behavior
Health-monitor stale-socket restarts should be handled gracefully without crashing the gateway process. \SafeGatewayPlugin\ should catch the reconnection failure and recover internally rather than throwing an uncaught exception.
Workaround
A 5-minute watchdog task (Windows Scheduled Task checking port 18789) limits downtime to under a minute per crash, but does not prevent the crash itself.
Update: This issue has been addressed by #55991 (merged into main). That fix adds abortSignal?.aborted as a safety net in drainPendingGatewayErrors, which covers the race window where lifecycleStopping hasn't been set yet.
Worth noting: #55000 addresses the root cause more directly — by calling gatewaySupervisor.detachLifecycle()beforegateway.disconnect() in onAbort(), the supervisor transitions to teardown phase first and suppresses the error before it ever reaches the lifecycle handler. No lifecycle-layer guard needed at all.
Closing as fixed upstream. This crash family was addressed by upstream Discord lifecycle changes merged in #55991, and PR #55000 was closed after the upstream maintainer confirmed the fix landed there.
If you still hit the same Max reconnect attempts (0) / stale-socket gateway crash on the latest OpenClaw release, comment here with fresh logs and version details and we can reopen or spin a new issue.
Activity
fix(discord): suppress expected reconnect-exhausted on stale-socket r…
rzblues commentedon Mar 28, 2026
Update: This issue has been addressed by #55991 (merged into main). That fix adds
abortSignal?.abortedas a safety net indrainPendingGatewayErrors, which covers the race window wherelifecycleStoppinghasn't been set yet.Worth noting: #55000 addresses the root cause more directly — by calling
gatewaySupervisor.detachLifecycle()beforegateway.disconnect()inonAbort(), the supervisor transitions to teardown phase first and suppresses the error before it ever reaches the lifecycle handler. No lifecycle-layer guard needed at all.Takhoffman commentedon Mar 29, 2026
Closing as fixed upstream. This crash family was addressed by upstream Discord lifecycle changes merged in #55991, and PR #55000 was closed after the upstream maintainer confirmed the fix landed there.
If you still hit the same
Max reconnect attempts (0)/ stale-socket gateway crash on the latest OpenClaw release, comment here with fresh logs and version details and we can reopen or spin a new issue.