Skip to content

Discord: handle early gateway startup errors#23832

Merged
steipete merged 1 commit intoopenclaw:mainfrom
theotarr:fix/discord-early-gateway-error-handling
Feb 26, 2026
Merged

Discord: handle early gateway startup errors#23832
steipete merged 1 commit intoopenclaw:mainfrom
theotarr:fix/discord-early-gateway-error-handling

Conversation

@theotarr
Copy link
Contributor

@theotarr theotarr commented Feb 22, 2026

Summary

  • buffer Discord gateway error events emitted during provider startup before lifecycle wait listeners are attached
  • drain queued startup errors when lifecycle begins, treating disallowed intents (4014) as actionable/non-crashing while preserving fail-fast behavior for other fatal gateway errors
  • add regression coverage for queued 4014, queued non-4014 fatal errors, and pre-lifecycle emission capture
  • add a changelog fix entry

Root Cause

A Discord gateway error could fire between client/plugin initialization and waitForDiscordGatewayStop listener registration. In that gap, Fatal Gateway error: 4014 events were not owned by lifecycle handling and could surface as uncaught process exceptions.

Testing

  • pnpm vitest run src/discord/monitor/provider.lifecycle.test.ts src/discord/monitor/provider.test.ts
  • pnpm exec oxlint --type-aware src/discord/monitor/provider.ts src/discord/monitor/provider.lifecycle.ts src/discord/monitor/provider.lifecycle.test.ts src/discord/monitor/provider.test.ts
  • pnpm exec oxfmt --check CHANGELOG.md src/discord/monitor/provider.ts src/discord/monitor/provider.lifecycle.ts src/discord/monitor/provider.lifecycle.test.ts src/discord/monitor/provider.test.ts

Greptile Summary

Buffers Discord gateway error events during provider startup to prevent uncaught exceptions when errors fire before lifecycle listeners attach. Disallowed intents (4014) are handled as actionable configuration guidance, while other fatal gateway errors preserve fail-fast behavior. Adds comprehensive test coverage for queued error scenarios and CHANGELOG entry.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Well-architected fix for a specific race condition with proper error handling, comprehensive test coverage (3 new test cases covering all scenarios), and clean resource management via finally blocks. The implementation follows existing patterns and maintains fail-fast behavior for fatal errors while gracefully handling the targeted 4014 intent issue.
  • No files require special attention

Last reviewed commit: 8e380bd

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle bot added channel: discord Channel integration: discord size: M labels Feb 22, 2026
@vincentkoc vincentkoc force-pushed the fix/discord-early-gateway-error-handling branch from 8e380bd to dea5d80 Compare February 22, 2026 19:50
@steipete steipete force-pushed the fix/discord-early-gateway-error-handling branch from dea5d80 to d1419bc Compare February 26, 2026 03:22
@steipete steipete merged commit 7af6849 into openclaw:main Feb 26, 2026
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: fast-path merge requested by maintainer; rebased and resolved CHANGELOG conflict.
  • Land commit: d1419bc
  • Merge commit: 7af6849

Thanks @theotarr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants