Skip to content

fix(discord): recover from failed gateway resumes#103596

Merged
steipete merged 2 commits into
mainfrom
codex/fix-discord-resume-fallback
Jul 10, 2026
Merged

fix(discord): recover from failed gateway resumes#103596
steipete merged 2 commits into
mainfrom
codex/fix-discord-resume-fallback

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #99681

AI-assisted: Codex implemented, tested, live-validated, and reviewed this repair.

What Problem This Solves

Fixes an issue where Discord channels could remain disconnected indefinitely after an abnormal Gateway close when Discord repeatedly rejected the cached RESUME session. Operators also lacked truthful reconnect logs showing whether the next attempt would RESUME or perform a fresh IDENTIFY.

Why This Change Was Made

The Discord-owned Gateway now treats RESUME eligibility as complete session state, tracks consecutive unsuccessful RESUME connection attempts, and discards the poisoned session after three failures so the next reconnect performs a fresh IDENTIFY. READY, RESUMED, explicit disconnect, and session invalidation reset the streak; reconnect logs report the strategy actually scheduled.

This restores the recovery invariant that was lost when the previous Carbon Gateway dependency was internalized, without adding another lifecycle-controller restart path.

User Impact

Discord delivery can recover from repeated RESUME rejection without restarting the OpenClaw Gateway process. Operators now see the reconnect reason, delay, and actual resume=true|false strategy in normal Gateway logs.

Evidence

  • Focused Blacksmith Testbox proof on current main: 50/50 tests passed across gateway.test.ts, gateway-logging.test.ts, and provider.lifecycle.test.ts (tbx_01kx5jgs88rfd2apfmaq46b0hs).
  • Targeted extension lint: 0 warnings and 0 errors. Targeted oxfmt --check: all three changed files correctly formatted.
  • Broad changed gate: all core/extension typechecks and core lint passed; its only finding was a redundant boolean conversion in this patch, which was removed before the final focused/lint reruns.
  • Exact synced AWS Crabbox build passed: run_be3c67948d38.
  • Live Discord fault injection passed on AWS Crabbox: run_536b7a74e5d4. The lane completed a real roundtrip, destroyed the active transport, rejected three RESUME reconnects, observed forced fresh IDENTIFY, recovered on the same live Gateway PID with no restart marker, and completed a second real roundtrip.
  • Redacted live result: pidStable=true, resumeSchedules=3, forcedIdentify=true, reconnected=true, baselineRoundtrip=true, postRecoveryRoundtrip=true.
  • Fresh structured Codex autoreview: clean, no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: M maintainer Maintainer-authored PR labels Jul 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof completed for exact PR head fed12c5f9a1a30c59b57e24795c6d122cfae0b1e.

What changed:

  • Before: the internal Discord Gateway could schedule the cached RESUME session until the 50-attempt ceiling, with no three-failure IDENTIFY fallback and no truthful schedule diagnostics.
  • After: three unsuccessful RESUME connection attempts discard the stale session and schedule a fresh IDENTIFY; logs include the reconnect reason, delay, and actual resume=true|false strategy.

Validation:

  • pnpm test extensions/discord/src/internal/gateway.test.ts extensions/discord/src/gateway-logging.test.ts extensions/discord/src/monitor/provider.lifecycle.test.ts — 50/50 passed on Blacksmith Testbox tbx_01kx5jgs88rfd2apfmaq46b0hs.
  • pnpm exec oxlint --tsconfig config/tsconfig/oxlint.extensions.json extensions/discord/src/internal/gateway.ts extensions/discord/src/internal/gateway.test.ts — 0 warnings, 0 errors.
  • pnpm exec oxfmt --check --threads=1 extensions/discord/src/internal/gateway.ts extensions/discord/src/internal/gateway.test.ts — passed.
  • pnpm build — passed on direct AWS Crabbox run run_be3c67948d38.
  • Live Discord direct-AWS Crabbox fault injection — passed on run_536b7a74e5d4: real roundtrip before fault; active transport destroyed; exactly three RESUME schedules rejected; forced fresh IDENTIFY observed; original Gateway PID remained alive and unchanged; connected status restored; second real roundtrip passed.
  • Redacted live result: pidStable=true, resumeSchedules=3, forcedIdentify=true, reconnected=true, baselineRoundtrip=true, postRecoveryRoundtrip=true.
  • .agents/skills/autoreview/scripts/autoreview --mode local --stream-engine-output — clean; no accepted/actionable findings.
  • Exact-head hosted CI/Testbox: Actions run 29082556888 — success, no failed jobs.
  • Repo-native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 103596 — passed and recorded the exact-head hosted certification.

Known proof gaps: none for the changed Gateway reconnect surface. This is non-visual behavior, so screenshots are not applicable.

@steipete
steipete merged commit abbd5ae into main Jul 10, 2026
91 checks passed
@steipete
steipete deleted the codex/fix-discord-resume-fallback branch July 10, 2026 09:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
* fix(discord): recover from failed gateway resumes

* chore: leave release notes to release workflow
steipete added a commit that referenced this pull request Jul 11, 2026
* fix(discord): recover from failed gateway resumes

* chore: leave release notes to release workflow

(cherry picked from commit abbd5ae)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discord plugin does not auto-reconnect after 1006 WS close (forces full gateway restart, kills in-flight turns)

1 participant