Repository navigation
Description
Summary
On Windows with OpenClaw installed as a Scheduled Task gateway service, the gateway can crash the entire process during Discord stale-socket recovery and then later appear to "restart itself".
The important distinction is:
- the first failure is an internal OpenClaw crash
- the later reappearance makes it look like a generic self-restart / watchdog problem from the operator side
This is easy to misdiagnose unless you isolate external watchdogs and watch PID/task transitions directly.
Environment
- OpenClaw:
2026.3.24 - Platform: Windows
- Service mode: Scheduled Task (
OpenClaw Gateway) - Node:
22.x - Affected channel path: Discord stale-socket recovery / reconnect path
Core crash signature
From the gateway log:
[discord:default] health-monitor: restarting (reason: stale-socket)
Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
at SafeGatewayPlugin.handleReconnectionAttempt (...provider-CAlWEl41.js:3318:47)
This was followed by the gateway process disappearing.
Why this report matters specifically for Windows service installs
When OpenClaw runs under the Windows Scheduled Task gateway service, the operational view becomes confusing:
- Discord stale-socket recovery triggers an internal uncaught exception
- the full gateway process exits
- later, the gateway may come back under the task/service wrapper
- from the outside this looks like "OpenClaw crashed and restarted itself"
So the operator sees a restart loop, but the first event is actually an internal crash.
Isolation result (external watchdogs disabled)
To rule out external supervision, an external desktop watchdog process was stopped and an isolated monitor was started. The monitor only recorded:
- gateway PID / creation time changes
- task state changes
- process disappearance / reappearance
During that isolated window, the gateway still died on its own and later came back.
Sanitized monitor timeline
[2026-03-26 16:47:23] baseline gateway pid=31160 created=2026/3/26 16:24:16
[2026-03-26 16:47:25] baseline task state=Running enabled=True lastRun=2026/3/26 16:24:24 result=267009
[2026-03-26 16:59:30] task changed state=Ready enabled=True lastRun=2026/3/26 16:24:24 result=1
[2026-03-26 16:59:30] gateway disappeared previousPid=31160 previousCreated=2026/3/26 16:24:16
[2026-03-26 17:30:59] task changed state=Running enabled=True lastRun=2026/3/26 17:30:30 result=267009
[2026-03-26 17:30:59] gateway appeared pid=37052 created=2026/3/26 17:30:58
[2026-03-26 17:31:17] task changed state=Ready enabled=True lastRun=2026/3/26 17:30:30 result=1
[2026-03-26 17:31:17] gateway disappeared previousPid=37052 previousCreated=2026/3/26 17:30:58
[2026-03-26 17:31:20] task changed state=Running enabled=True lastRun=2026/3/26 17:31:31 result=267009
[2026-03-26 17:31:20] gateway appeared pid=27376 created=2026/3/26 17:31:18
What that proves
- the gateway did disappear on its own after external watchdog isolation
- therefore the failure cannot be explained purely by an external watchdog
- subsequent reappearance under the Windows task makes the issue look like a "self-restart" from the operator perspective
Additional Windows-specific observations
Gateway task behavior
The OpenClaw Gateway Scheduled Task is the wrapper used on this machine.
The task XML did not show an obvious RestartOnFailure policy, which makes the behavior especially confusing at first glance.
Why the service/task can still make this look like a self-restart
From an operator perspective, once the crashed gateway is later relaunched under the task wrapper, it is very easy to conclude:
- "OpenClaw crashed"
- "OpenClaw restarted itself"
Even though the root trigger was the internal Discord stale-socket crash path.
Relevant log evidence from the same run
The crash path was captured directly in the gateway file log:
2026-03-26T18:06:30.259+08:00 info gateway/health-monitor [discord:default] health-monitor: restarting (reason: stale-socket)
2026-03-26T18:06:30.487+08:00 error [openclaw] Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
This is the strongest evidence that the initial failure is an internal uncaught exception, not a generic Windows watchdog artifact.
Workaround that stopped this crash path
Disabling the channel health-monitor restart path prevented this specific failure mode from reproducing during follow-up observation:
{
"gateway": {
"channelHealthCheckMinutes": 0
}
}After restarting with that setting, startup logs no longer contained the normal health-monitor startup line:
gateway/health-monitor started (...)
and the stale-socket-triggered crash path did not reappear during the immediate observation window.
Expected behavior
A Discord stale-socket recovery attempt should not be able to crash the entire OpenClaw gateway process with an uncaught exception.
Even if reconnect attempts are exhausted, the failure should be handled gracefully and contained to the affected channel/provider.
Actual behavior
A Discord stale-socket recovery can produce:
Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
which terminates the full gateway process.
Related issues
This is likely related to the broader Discord reconnect / stale-socket crash family, for example:
- bug(discord): forced gateway reconnect crashes — reconnectAttempts never reset before disconnect/connect cycles #55116
- Discord health monitor triggers uncaught exception → gateway crash (2026.3.24) #55026
I am opening this separately because the Windows Scheduled Task deployment changes how the failure looks operationally: it presents as a crash followed by an apparent self-restart sequence, which is easy to misattribute to generic watchdog behavior.
Privacy note
This report intentionally excludes private tokens, chat identifiers, local personal data, and machine-specific secrets. Only sanitized timing, PID transitions, and public log signatures are included.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
SUSRDev commentedon Mar 26, 2026
Relation to existing issues:
So the intended value of this issue is:
If maintainers prefer, this can be closed as a duplicate of #55116 after the Windows-specific notes are captured there.
steipete commentedon Mar 26, 2026
Closing as a duplicate of #54894.
The Windows Scheduled Task evidence here is useful, but the underlying failure is the same Discord stale-socket or abort crash fixed by #55000 and tracked in #54931:
Max reconnect attempts (0)Keeping canonical tracking on #54894 and the fix discussion on #55000.