openclaw - 💡(How to fix) Fix [Bug] Discord gateway race condition - 'awaiting gateway readiness' on cold start [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#61703Fetched 2026-04-08 02:55:41
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Timeline (top)
commented ×1

Discord client gets stuck on "awaiting gateway readiness" on cold start due to a race condition where the gateway "ready" event fires before Discord client initialization completes.

Error Message

Cold Start (FAILURE):

{"subsystem":"gateway"} "ready (6 plugins, 1.0s)"
{"subsystem":"gateway/channels/discord"} "[default] starting provider (@marvin)"
{"subsystem":"gateway/channels/discord"} "discord users resolved: 238126776486854656, 685592070718488606"
{"subsystem":"gateway/channels/discord"} "discord client initialized as 1488941026524659916 (marvin); awaiting gateway readiness"
# No "logged in to discord" message

Hot Reload (SUCCESS):

{"subsystem":"gateway/reload"} "config change detected"
{"subsystem":"gateway/channels/discord"} "restarting discord channel"
{"subsystem":"gateway/channels/discord"} "logged in to discord as 1488941026524659916 (marvin)"

Root Cause

The Discord client initialization is asynchronous and takes ~15-20 seconds, but the gateway "ready" event fires immediately after plugins load (~1 second). The Discord client waits for a signal that's already been emitted.

Possible Fix: Ensure gateway waits for all channels to be "ready" before emitting the global "ready" event, OR have Discord client check if gateway is already ready on initialization.

Fix Action

Workaround

Trigger a config hot reload after cold start:

  1. Start OpenClaw: openclaw gateway run
  2. Wait for gateway to start
  3. Touch config: touch ~/.openclaw/openclaw.json
  4. Gateway hot-reloads and Discord logs in successfully

Code Example

04:45:11 - Gateway "ready (6 plugins, 1.0s)" fires
04:45:18 - Discord "starting provider (@marvin)"
04:45:18 - Discord "discord users resolved: ..."
04:45:35 - Discord "discord client initialized...awaiting gateway readiness"

---

T+1.0s:  Gateway emits "ready (X plugins, Ys)"
T+7s:    Discord provider starts
T+9s:    Discord users resolved
T+16s:   Discord client initialized
T+16s:   "awaiting gateway readiness" (waits forever)

---

T+0s:    Gateway already running and "ready"
T+1s:    Discord provider restarts
T+2s:    Discord "logged in to discord" (SUCCESS)

---

{"subsystem":"gateway"} "ready (6 plugins, 1.0s)"
{"subsystem":"gateway/channels/discord"} "[default] starting provider (@marvin)"
{"subsystem":"gateway/channels/discord"} "discord users resolved: 238126776486854656, 685592070718488606"
{"subsystem":"gateway/channels/discord"} "discord client initialized as 1488941026524659916 (marvin); awaiting gateway readiness"
# No "logged in to discord" message

---

{"subsystem":"gateway/reload"} "config change detected"
{"subsystem":"gateway/channels/discord"} "restarting discord channel"
{"subsystem":"gateway/channels/discord"} "logged in to discord as 1488941026524659916 (marvin)"
RAW_BUFFERClick to expand / collapse

OpenClaw Bug Report: Discord Gateway Race Condition

Summary

Discord client gets stuck on "awaiting gateway readiness" on cold start due to a race condition where the gateway "ready" event fires before Discord client initialization completes.

Environment

  • OpenClaw Versions Affected: 2026.4.1 (da64a97), 2026.4.2 (d74a122), 2026.4.5 (3e72c03)
  • Runtime: Node.js v22.22.2
  • OS: Linux Ubuntu 22.04
  • Deployment: GCP VM and Docker

Steps to Reproduce

  1. Configure OpenClaw with Discord channel enabled
  2. Start OpenClaw gateway: openclaw gateway run
  3. Observe logs for Discord initialization

Expected Behavior

Discord client should initialize and receive the gateway "ready" event, then log in successfully to Discord.

Actual Behavior

Discord client initializes AFTER gateway "ready" event fires:

04:45:11 - Gateway "ready (6 plugins, 1.0s)" fires
04:45:18 - Discord "starting provider (@marvin)"
04:45:18 - Discord "discord users resolved: ..."
04:45:35 - Discord "discord client initialized...awaiting gateway readiness"

Discord waits forever for "gateway readiness" signal that already fired 24 seconds earlier.

Race Condition Details

Timeline on Cold Start:

T+1.0s:  Gateway emits "ready (X plugins, Ys)"
T+7s:    Discord provider starts
T+9s:    Discord users resolved
T+16s:   Discord client initialized
T+16s:   "awaiting gateway readiness" (waits forever)

Timeline on Hot Reload (when it works):

T+0s:    Gateway already running and "ready"
T+1s:    Discord provider restarts
T+2s:    Discord "logged in to discord" (SUCCESS)

Workaround

Trigger a config hot reload after cold start:

  1. Start OpenClaw: openclaw gateway run
  2. Wait for gateway to start
  3. Touch config: touch ~/.openclaw/openclaw.json
  4. Gateway hot-reloads and Discord logs in successfully

Logs

Cold Start (FAILURE):

{"subsystem":"gateway"} "ready (6 plugins, 1.0s)"
{"subsystem":"gateway/channels/discord"} "[default] starting provider (@marvin)"
{"subsystem":"gateway/channels/discord"} "discord users resolved: 238126776486854656, 685592070718488606"
{"subsystem":"gateway/channels/discord"} "discord client initialized as 1488941026524659916 (marvin); awaiting gateway readiness"
# No "logged in to discord" message

Hot Reload (SUCCESS):

{"subsystem":"gateway/reload"} "config change detected"
{"subsystem":"gateway/channels/discord"} "restarting discord channel"
{"subsystem":"gateway/channels/discord"} "logged in to discord as 1488941026524659916 (marvin)"

Root Cause Analysis

The Discord client initialization is asynchronous and takes ~15-20 seconds, but the gateway "ready" event fires immediately after plugins load (~1 second). The Discord client waits for a signal that's already been emitted.

Possible Fix: Ensure gateway waits for all channels to be "ready" before emitting the global "ready" event, OR have Discord client check if gateway is already ready on initialization.

Impact

  • Discord bots cannot connect to Discord on cold start
  • Requires manual hot reload workaround
  • Affects all OpenClaw versions tested (2026.4.1 - 2026.4.5)

Additional Context

  • The bug is intermittent - sometimes Discord initializes fast enough to catch the ready event
  • Observed on both GCP VM and Docker deployments
  • Happens with both "qmd" and "builtin" memory backends
  • Not specific to any Discord token or bot account

extent analysis

TL;DR

Modify the gateway to wait for all channels, including Discord, to be ready before emitting the global "ready" event, or implement a check in the Discord client to verify if the gateway is already ready upon initialization.

Guidance

  • Review the gateway's event emission logic to ensure it accounts for asynchronous channel initializations, such as Discord's 15-20 second delay.
  • Consider implementing a mechanism for the Discord client to check the gateway's status upon initialization, allowing it to proceed if the gateway is already ready.
  • Evaluate the feasibility of introducing a delay or a synchronization mechanism to ensure the gateway's "ready" event fires after all channels have initialized.
  • Investigate the intermittent nature of the bug to identify any patterns or conditions that might influence the timing of the Discord client initialization and the gateway "ready" event.

Example

A potential code adjustment could involve adding a check in the Discord client initialization to verify the gateway's readiness:

if (gatewayStatus === 'ready') {
  // Proceed with Discord client initialization
} else {
  // Wait for gateway ready event or implement a retry mechanism
}

Notes

The exact implementation details will depend on the specific architecture and requirements of the OpenClaw system. It's essential to ensure that any changes do not introduce new issues or affect the performance of other components.

Recommendation

Apply a workaround by modifying the gateway or Discord client logic to synchronize their readiness states, as a permanent fix may require significant changes to the underlying architecture. This approach allows for a more immediate resolution to the issue while a more comprehensive solution is developed.

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

openclaw - 💡(How to fix) Fix [Bug] Discord gateway race condition - 'awaiting gateway readiness' on cold start [1 comments, 2 participants]