Repository navigation
Description
Summary
When a Discord bot is missing Privileged Gateway Intents (e.g. Message Content Intent), Discord sends WebSocket close code 4014. OpenClaw does not catch this error — it propagates as an uncaught exception that kills the entire gateway process, taking down all channels (Telegram, Slack, WhatsApp, etc.) alongside Discord.
This is a critical reliability issue: a misconfigured Discord bot should only disable the Discord channel, not crash the whole bot.
Error
[openclaw] Uncaught exception: Error: Fatal Gateway error: 4014
at GatewayPlugin.handleReconnectionAttempt (.../@buape/carbon/GatewayPlugin.ts:420:7)
at GatewayPlugin.handleClose (.../@buape/carbon/GatewayPlugin.ts:469:8)
When It Is Encountered
- User enables the Discord channel plugin in OpenClaw
- The Discord bot token is valid, but one or more Privileged Gateway Intents are not enabled in the Discord Developer Portal (e.g. Message Content Intent, Server Members Intent, Presence Intent)
- OpenClaw connects to Discord; Discord immediately sends close code 4014 during handshake
- The
@buape/carbonGatewayPlugin.handleReconnectionAttemptthrowsFatal Gateway error: 4014 - This throw happens before OpenClaw attaches an error listener to the gateway emitter
- Node.js treats unhandled
EventEmitter"error"events as uncaught exceptions → process exits
How to Reproduce
- Go to Discord Developer Portal → your application → Bot
- Under Privileged Gateway Intents, disable Message Content Intent (or leave it disabled)
- Configure OpenClaw with that bot token:
channels: {
discord: {
enabled: true,
token: "<your-bot-token>",
// ...
}
}- Start or restart the OpenClaw gateway
- Result: Gateway process exits with
Uncaught exception: Error: Fatal Gateway error: 4014 - Expected: Discord channel fails gracefully with an actionable error message; all other channels (Telegram, Slack, etc.) continue working
Root Cause
Error propagation path:
Carbon GatewayPlugin.handleClose()
→ handleReconnectionAttempt() throws Error("Fatal Gateway error: 4014")
→ surfaces as "error" event on the gateway EventEmitter
→ OpenClaw attaches its error listener too late (after several awaits:
deployDiscordCommands, identity fetch, etc.)
→ no listener attached at event time
→ Node.js default: unhandled EventEmitter "error" → uncaught exception → process crash
Close code 4014 is non-recoverable — reconnection attempts will always fail until the user manually enables intents in the Discord Developer Portal. The gateway should stop reconnecting and surface a clear diagnostic instead.
Expected Behavior
- Attach an early
gatewayEmitter.on("error", ...)listener before any async operations that could allow gateway events to fire - On close code 4014: log a clear, actionable message:
Discord: Missing Privileged Gateway Intents. Go to Discord Developer Portal → Your App → Bot → enable required intents (e.g. Message Content Intent).
- Disable reconnection attempts (non-recoverable error)
- Shut down only the Discord channel — all other channels remain running
- Do NOT propagate as uncaught exception
Comparison with Other Providers
Telegram and Slack providers use explicit bot.catch(...) / monitor catch patterns to contain provider-level failures. The Discord provider should follow the same containment principle for gateway error events rather than relying on uncaught exception behavior.
Prior Issues
- [Bug]: Uncaught exception: Error: Fatal Gateway error: 4014 #468 (closed, no fix)
- Discord WebSocket resume loop never recovers — needs circuit breaker / fresh IDENTIFY fallback #14331 (closed)
- Discord zombie WebSocket reconnect loop crashes gateway repeatedly #14703 (closed)
- Discord WebSocket: add circuit breaker / async recovery for zombie reconnect loops #14758 (closed)
This issue persists across all prior reports and has never been resolved.
Environment
- OpenClaw version: v2026.2.18+
- Channel: Discord (plugin:
@buape/carbonGatewayPlugin) - Trigger: Any bot with missing Privileged Gateway Intents
- Impact: Full gateway crash — all channels go down
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
thewilloftheshadow commentedon Feb 19, 2026
Fixed in f7a8c2d
mudrii commentedon Feb 20, 2026
thewilloftheshadow commentedon Feb 20, 2026
Sorry, I didn't see that PR. We're all getting swarmed by dozens of people constantly pinging us every hour to review things and also constantly having to look at bug reports as well as implement the other things we were planning to implement.
I actually hadn't seen this issue yet either when I made the commit, I implemented it on my own and then saw the issue while I was searching
mudrii commentedon Feb 20, 2026
thewilloftheshadow commentedon Feb 20, 2026
@mudrii if you have it happen again with the commit that I pushed, please open a new PR and ping me with it in our discord in the collaborators channel
(to everyone else reading this, no don't do this with your own PRs smh)