Skip to content

Windows Scheduled Task deployment: Discord stale-socket crash looks like self-restarting gateway #55164

Closed

Description

@SUSRDev

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:

  1. Discord stale-socket recovery triggers an internal uncaught exception
  2. the full gateway process exits
  3. later, the gateway may come back under the task/service wrapper
  4. 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:

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.

Activity

  1. SUSRDev commented on Mar 26, 2026

    @SUSRDev
    Author

    Relation to existing issues:

    So the intended value of this issue is:

    1. preserve the Windows-specific operational evidence
    2. document the crash → apparent self-restart sequence seen by operators
    3. make it easier to connect field reports that initially look unrelated to the Discord reconnect bug family

    If maintainers prefer, this can be closed as a duplicate of #55116 after the Windows-specific notes are captured there.

  2. steipete commented on Mar 26, 2026

    @steipete
    Contributor

    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:

    • abort sets reconnect maxAttempts to 0
    • disconnect emits Max reconnect attempts (0)
    • that teardown error can take down the full gateway process

    Keeping canonical tracking on #54894 and the fix discussion on #55000.

  3. locked as resolved and limited conversation to collaborators on Mar 29, 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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions