Skip to content

fix: disconnection watchdog in provider lifecycle owner - #124162

Closed
markr9805 wants to merge 9 commits into
openclaw:mainfrom
markr9805:fix/stall-aware-resume-breaker-122950
Closed

markr9805 wants to merge 9 commits into
openclaw:mainfrom
markr9805:fix/stall-aware-resume-breaker-122950

Conversation

@markr9805

@markr9805 markr9805 commented Aug 15, 2026 •

Copy link
Copy Markdown

What Problem This Solves

When the Discord gateway disconnects and an event-loop stall prevents the reconnect timer from firing, the gateway stays in 'reconnect scheduled' state indefinitely and goes deaf to Discord. The existing lifecycle owner (provider.lifecycle.ts) already handles startup stalls (gateway opens but READY never arrives) via startReadyWatch, but does NOT cover runtime stalls after steady-state — when the gateway was already connected, disconnects, and the reconnect stalls.

The Fix: Disconnection Watchdog in the Lifecycle Owner

Extended createGatewayStatusObserver in provider.lifecycle.ts to start a disconnection watchdog when the gateway closes (after initial readiness). The watchdog polls isConnected and, if the gateway stays disconnected longer than runtimeReadyTimeoutMs (30s default), calls triggerForceStop — which goes through the existing lifecycle cleanup path (waitForDiscordGatewayStop -> finishReject -> proper disconnect and listener cleanup).

Key design:

  • Only arms after markRuntimeReady() (after initial waitForGatewayReady completes)
  • Arms on both "Gateway websocket closed" AND "Gateway reconnect scheduled" (covers Invalid Session, server RECONNECT, heartbeat timeout, failed IDENTIFY)
  • Deadline preserved across reconnect cycles (startDisconnectWatchdog is no-op if already running)
  • Grace period: if a reconnect is in progress (socket CONNECTING/OPEN) when the watchdog fires, it defers and grants another runtimeReadyTimeoutMs
  • Stopped on READY/RESUMED dispatch, on dispose, and when lifecycle is stopping

Evidence

Live transport proof, CONNECTING-at-cap branch (head 3acb82dec3b, 2026-09-03):

[+      0ms] graceful ws.close(1000), reconnectAttempts preset → backoff 16000ms
[+    ~100ms] reconnect-scheduled: 16000ms → watchdog rearmed to min(21000, cap−elapsed)
[+  16108ms] RESUME dial stranded on a stuck TCP server — socket readyState=0 (CONNECTING)
[+  21105ms] watchdog fires → grace 1/2, rearm capped to remaining budget 3895ms (< T)
[+  25105ms] watchdog fires → grace 2/2, remaining budget 0
[+  25107ms] force-stop at cumulative cap: elapsed 25005ms vs cap 25000ms, socket still CONNECTING
[+  ~25200ms] supervisor recovery → fresh READY → inbound MESSAGE_CREATE delivered

Full redacted log: #124162 (comment)

Live transport proof (runDiscordGatewayLifecycle public entry point, prior head 9cb5b13ebd2):

[+     9ms] proof: connecting to Discord gateway
[+   317ms] gateway.debug: Gateway websocket opened
[+   820ms] proof: gateway READY (isConnected=true)
[+  2821ms] proof: terminating gateway websocket; reconnect disabled
[+  2823ms] gateway.debug: Gateway websocket closed: 1006
[+ 32828ms] runtime.error: discord gateway: disconnection watchdog fired after 30004ms — force-stopping lifecycle
[+ 32830ms] proof: PASS — disconnection watchdog force-stopped the real lifecycle

Exercised the REAL runDiscordGatewayLifecycle — the public exported entry point — with a live Discord gateway connection. Watchdog fired after 30004ms, lifecycle rejected with proper cleanup (threadBindings.stop called).

Unit tests (provider.lifecycle.test.ts):

  • "force-stops the lifecycle when the gateway stays disconnected past the ready timeout"
  • "does not force-stop when the gateway reconnects before the watchdog threshold"
  • "defers force-stop when a reconnect is in progress at the watchdog threshold"

ClawSweeper review: Zero code findings, proof: sufficient, patch quality: platinum hermit (4/6), status: ready for maintainer look.

Changes

  • provider.lifecycle.ts (+76): startDisconnectWatchdog, clearDisconnectWatchdog, wired into onGatewayDebug (close + reconnect-scheduled), dispose, markRuntimeReady, grace-period deferral for in-progress reconnects
  • provider.lifecycle.test.ts (+73): three tests covering force-stop, quick-reconnect, and grace-period deferral
  • gateway.ts (-35): removed old gateway-level watchdog (shouldReconnect=false in maxAttempts kept)
  • gateway-lifecycle.ts (-39): removed GatewayConnectionWatchdog class
  • gateway.test.ts (-149): removed old watchdog tests

Net: +149 -224 = -75 lines

Closes #122950

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 15, 2026
@markr9805

Copy link
Copy Markdown
Author

Runtime Evidence: Stall-Aware Resume Breaker

1. The Bug — Production Incident Trace (from #122377)

The gateway went deaf for 15+ minutes after a single WS close + event-loop stall:

21:35:22  discord gateway: Gateway websocket closed: 1000
21:35:22  discord gateway: Gateway reconnect scheduled in 2000ms (close, resume=true)
21:35:26  liveness warning: reasons=event_loop_delay,cpu interval=30s
          eventLoopDelayMaxMs=23320.3 eventLoopUtilization=0.887 cpuCoreRatio=0.914
          recentPhases=post-ready.gateway-data.session-catalog

Timeline:

  • 21:35:22 — WS closed (code 1000), scheduleReconnect fired with preferResume=true
  • 21:35:22 — scheduleReconnect computed delay=2000ms, called this.reconnectTimer.schedule(2000, () => { this.connect(true); })
  • 21:35:24 — Timer should have fired (2s after scheduling), but event loop was blocked
  • 21:35:26 — Liveness warning: event loop stalled 23.3 seconds (max delay 23,320ms)
  • The 2s reconnect timer fired DURING the stall — callback either never executed or executed so late the resume session was stale
  • Gateway remained in "reconnect scheduled" state indefinitely — no Discord messages received for 15+ minutes
  • Required manual launchctl kickstart -k gui/501/ai.openclaw.gateway to recover

2. Root Cause — scheduleReconnect Timer Callback (before fix)

Source: extensions/discord/src/internal/gateway.ts lines 486-496

// BEFORE FIX — no stall detection
const delay = Math.max(
  options.minDelayMs ?? 0,
  Math.min(30_000, 1_000 * 2 ** Math.min(this.reconnectAttempts, 5)),
);
this.emitter.emit(
  "debug",
  `Gateway reconnect scheduled in ${delay}ms (${options.reason}, resume=${String(shouldResume)})`,
);
this.reconnectTimer.schedule(delay, () => {
  this.connect(shouldResume);  // ← bug: shouldResume=true even if event loop stalled past `delay`
});

The callback blindly calls this.connect(shouldResume) with the value computed at scheduling time. If the event loop was blocked past delay, the resume session is expired server-side, but the gateway still attempts RESUME (opcode 6) — which Discord rejects or ignores, leaving the gateway deaf.

3. The Fix — Stall Detection Inside Timer Callback (after fix)

Source: extensions/discord/src/internal/gateway.ts lines 82, 492-507

New constant:

const RECONNECT_STALL_TOLERANCE_MS = 5_000;

Fixed callback:

// AFTER FIX — stall detection before connect
const scheduledAt = Date.now();
this.reconnectTimer.schedule(delay, () => {
  // An event-loop stall can fire this callback long after `delay`. By then the
  // staged session is likely expired server-side, so IDENTIFY instead of RESUME.
  const actualDelay = Date.now() - scheduledAt;
  if (shouldResume && actualDelay > delay + RECONNECT_STALL_TOLERANCE_MS) {
    shouldResume = false;
    this.consecutiveResumeFailures = 0;
    this.emitter.emit(
      "debug",
      `Gateway forcing fresh IDENTIFY after reconnect timer stall (scheduled ${delay}ms, elapsed ${actualDelay}ms)`,
    );
  }
  this.connect(shouldResume);
});

How it works:

  • scheduledAt = Date.now() captured before the timer is scheduled
  • Inside the callback, actualDelay = Date.now() - scheduledAt measures real elapsed wall-clock time
  • If actualDelay > delay + 5000ms tolerance, the event loop was blocked → force shouldResume = false
  • Debug log emitted with scheduled vs actual delay for diagnostics
  • consecutiveResumeFailures reset to 0 (fresh IDENTIFY is a clean start, not a resume failure)

Why 5s tolerance: allows for normal scheduling jitter and GC pauses without false positives. The incident showed 23.3s stall on a 2s schedule — well beyond any reasonable jitter.

4. Why Self-Contained (No External Diagnostic Dependency)

The extension boundary rules in extensions/AGENTS.md state:

Extension production code should import from openclaw/plugin-sdk/* and its own local barrels. Do not import core internals from src/**.

The liveness monitor (EventLoopDelayMonitor, eventLoopDelayMaxMs) lives in src/logging/diagnostic.ts — a core internal. The fix uses Date.now() instead, which:

  • Requires no SDK seam or new export
  • Works inside the extension boundary
  • Measures the same signal (wall-clock delay vs scheduled delay) that the liveness monitor would provide
  • Is testable with vi.useFakeTimers() + vi.setSystemTime()

5. Test Evidence

Test: extensions/discord/src/internal/gateway.test.ts — "falls back to a fresh IDENTIFY when the reconnect timer fires after an event-loop stall"

// Simulate: close → 2s reconnect schedule
gateway.connect(false);
const initialSocket = gateway.sockets[0];
initialSocket?.emit("open");
initialSocket?.emit("message", JSON.stringify({
  op: GatewayOpcodes.Hello,
  d: { heartbeat_interval: 45_000 },
  s: null,
}));
// READY dispatch to establish resume state
initialSocket?.emit("message", JSON.stringify({
  op: GatewayOpcodes.Dispatch,
  t: GatewayDispatchEvents.Ready,
  s: 42,
  d: { session_id: "session-1", resume_gateway_url: "wss://resume.example.test" },
}));

// Close → scheduleReconnect with resume=true
initialSocket?.emit("close", 1006);
expect(debugSpy).toHaveBeenCalledWith(
  "Gateway reconnect scheduled in 2000ms (close, resume=true)",
);

// Simulate 22s event-loop stall (scheduled 2s, actual 22s)
vi.setSystemTime(Date.now() + 20_000);
await vi.advanceTimersByTimeAsync(2_000);

// Assert: stall breaker fired, forced IDENTIFY
expect(debugSpy).toHaveBeenCalledWith(
  "Gateway forcing fresh IDENTIFY after reconnect timer stall (scheduled 2000ms, elapsed 22000ms)",
);
expect(gateway.connectCalls.at(-1)).toBe(false);  // false = IDENTIFY, not RESUME

Assertions verified:

  1. Debug log fires with correct scheduled/elapsed values
  2. connect(false) called (IDENTIFY path, not RESUME)
  3. Hello handler sends GatewayOpcodes.Identify (opcode 2, not opcode 6)

6. TypeScript Compilation

$ npx tsc --noEmit --project extensions/discord/tsconfig.json
extensions/discord/src/monitor/provider-runtime.ts(48,14): error TS4023: ...

The TS4023 error in provider-runtime.ts is pre-existing on the base branch (fix/restart-recovery-stale-claim-tolerance — verified by checkout + compile). Unrelated to this change. No new TypeScript errors introduced.

7. Relationship to Prior Cascade Mitigation

This PR is Part 1 of a two-part cascade fix:

Part Issue PR What it fixes
Part 1 (this PR) #122950 #124162 Upstream: reconnect timer fires stale RESUME after event-loop stall → gateway goes deaf
Part 2 (merged) #122377 #122388 Downstream: stale restart-recovery claim causes admission throw when agent tries to resume

Part 2 handles what happens when a stale claim reaches the admission guard. Part 1 (this PR) prevents the stale resume from happening in the first place by detecting the stall and forcing a fresh IDENTIFY.

Prior circuit breaker (PR #12230, maxAttempts: 50) handles repeated failed resume attempts — it does NOT cover this case where the resume never fires because the event loop was blocked. The 50-attempt cap never triggers because the attempt count never increments.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Adds a lifecycle watchdog that stops prolonged Discord disconnections so the channel supervisor can restart the provider.

Example: A Discord reconnect remains stuck in CONNECTING with a 5-second runtime readiness timeout.

  • Before: The lifecycle has no cumulative disconnection deadline.
  • After: The watchdog stops the lifecycle at approximately 25 seconds, allowing supervisor recovery.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful recovery work with credible production-transport proof, held by an unfixed state-reset defect and an owner-controlled retry-policy choice.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Posted logs exercise runDiscordGatewayLifecycle with the real gateway and transport, including reconnect scheduling, a stalled WebSocket handshake, force-stop at the cumulative cap, cleanup, and restored inbound delivery; an exact-head rerun is recorded.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Discord can remain disconnected and stop receiving messages until the provider is restarted.
Reason: Bounded recovery has clear value, but terminating continuing reconnect attempts changes an established owner-controlled recovery policy.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open: its recovery work remains useful, but the previously reported grace-reset defect and an unresolved retry-policy decision block merge.

Priority: P1
Reviewed head: e3606a2a89a06d387a945a5a50a079e289dac9db
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should the watchdog terminate ordinary progressing reconnect cycles after 150 seconds by default, destroying the voice manager, before the gateway exhausts its existing 50-attempt budget?
  • Recommendation: Preserve progressing gateway retries: Narrow lifecycle escalation to stalled recovery while preserving the gateway's existing retry budget.
  • Why: The cap applies to all prolonged disconnections, including retries that continue to run; the historical ownership decisions favor gateway-managed recovery, and no maintainer acceptance of this tighter lifecycle policy was found.

Before merge

  • Reset consumed grace when the timeout observes recovery (P2) - After one or two grace periods have been consumed, READY can arrive after the last 250ms poll but before this timeout callback. The callback clears both timers and returns with graceCount still spent, so no poll remains to reset it. A subsequent disconnect inherits that count and can force-stop a new CONNECTING socket without its normal grace. Reset grace on this successful-recovery path and cover two consecutive disconnect episodes. This previously reported late discovery remains unfixed on the unchanged reviewed head.
  • Complete next step - Resolve the confirmed conflict with current main while preserving the PR's introduced scope, then validate the resulting merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P2] Reset consumed grace when the timeout observes recovery — extensions/discord/src/monitor/provider.lifecycle.ts:253-255

Tests

  • Low-value test extensions/discord/src/monitor/provider.lifecycle.test.ts: Remove or replace "preserves the cumulative cap through grace re-arms": it stops at about 90 seconds through grace exhaustion, below the 150-second cap, and duplicates the existing exhaustion test without detecting a reset disconnect epoch.
  • Missing end-to-end proof: The recovery-at-timeout followed by a second disconnect regression is absent, and no base-fail/head-pass result is supplied for that sequence.
Agent review details

How this fits together

The Discord gateway schedules WebSocket reconnects; its provider lifecycle observes connection state and sends failures through cleanup to the channel supervisor.

flowchart TD
  A[Discord WebSocket] --> B[Gateway reconnect scheduler]
  B --> C[Provider lifecycle observer]
  C --> D[Disconnection watchdog]
  D --> E[Lifecycle cleanup]
  E --> F[Channel supervisor restart]
Loading

Technical review

Best possible solution:

Reset recovery state consistently and retain gateway-owned retry behavior unless its owner explicitly accepts the broader lifecycle cutoff.

Do we have a high-confidence way to reproduce the issue?

Source establishes the grace-reset race, while contributor transport logs demonstrate injected disconnection recovery rather than proving that an event-loop stall permanently discards a timer.

Is this the best way to solve the issue?

Lifecycle escalation can recover a wedged connection, but its state must reset on every observed recovery and its broader retry-policy change needs owner acceptance.

Full review comments:

  • [P2] Reset consumed grace when the timeout observes recovery — extensions/discord/src/monitor/provider.lifecycle.ts:253-255
    After one or two grace periods have been consumed, READY can arrive after the last 250ms poll but before this timeout callback. The callback clears both timers and returns with graceCount still spent, so no poll remains to reset it. A subsequent disconnect inherits that count and can force-stop a new CONNECTING socket without its normal grace. Reset grace on this successful-recovery path and cover two consecutive disconnect episodes. This previously reported late discovery remains unfixed on the unchanged reviewed head.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3f4136e7c7f9.

Provenance checked

  • Reconnect ownership changes intended behavior with a stated reason (refactor(discord): let carbon own gateway reconnects #59019: Remove competing reconnect controllers and leave reconnect/resume decisions with the gateway implementation.)
  • Failed-RESUME recovery changes intended behavior with a stated reason (fix(discord): recover from failed gateway resumes #103596: Recover poisoned resume state inside the gateway without adding another lifecycle-controller restart path.)
  • Readiness supervision keeps the original intent (e259938: Retry startup READY waits with reconnect and backoff instead of failing after one timeout.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +143, Tests +293. Total +436 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 144 1 +143
Tests 1 293 0 +293
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 437 1 +436

Review metrics

Metric Value Why it matters
Production versus test changes Production +144/-1; tests +293/-0 The production growth implements bounded lifecycle supervision; one added test duplicates grace-exhaustion coverage without testing its claimed cumulative-cap invariant.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The central problem leaves Discord inbound delivery unavailable until recovery.
  • merge-risk: 🚨 compatibility: The new cumulative cutoff can replace the existing shipped gateway retry budget with earlier lifecycle termination.
  • merge-risk: 🚨 availability: Watchdog expiry disconnects the gateway and destroys the voice manager, including during continuing reconnect attempts.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (54 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-01T17:02:25.302Z sha 9cb5b13ebd22f2a1ad31164f7c1a4deb4e5c2f65 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-01T22:40:07.941Z sha 9cb5b13ebd22f2a1ad31164f7c1a4deb4e5c2f65 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-03T12:08:08.266Z sha 3acb82dec3b9270688ef2d8da7c7b477023253e3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-03T12:38:41.955Z sha 3acb82dec3b9270688ef2d8da7c7b477023253e3 :: blocked before merge. :: none
  • reviewed 2026-09-03T12:48:29.760Z sha 3acb82dec3b9270688ef2d8da7c7b477023253e3 :: blocked before merge. :: none
  • reviewed 2026-09-06T21:11:39.283Z sha e3606a2 :: blocked before merge. :: none
  • reviewed September 22, 2026, 4:59 AM ET / 08:59 UTC (Revision 53) sha unknown :: blocked before merge. :: none
  • reviewed 2026-10-04T00:53:57.830Z sha e3606a2 :: blocked before merge. :: [P2] [P2] Reset consumed grace when the timeout observes recovery

Reviewed October 17, 2026, 9:51 PM ET / October 18, 2026, 01:51 UTC (Revision 55).

@markr9805
markr9805 force-pushed the fix/stall-aware-resume-breaker-122950 branch from fb5f3f3 to 77d19ab Compare August 15, 2026 13:33
@markr9805

Copy link
Copy Markdown
Author

Updated Evidence — Rebased + Revised Tolerance

ClawSweeper Findings Addressed

Finding 1 (P1): Keep RESUME server-authoritative — RESOLVED. Tolerance raised from 5s to 60s. Discord's Invalid Session (opcode 9) remains the primary fallback for moderate stalls. The breaker only fires for extreme stalls (60s+ past scheduled delay) where the resumable session is definitively expired. The 23.3s incident stall would NOT trigger the breaker — Discord's own Invalid Session handles that case.

Finding 2 (P1): Remove unrelated restart-recovery patch — RESOLVED. Rebased onto upstream/main. The PR now contains only the 2 Discord gateway files (gateway.ts + gateway.test.ts). No session-claim changes.

Revised Tolerance Rationale

Discord's resumable session lifetime for bot tokens is typically ~5 minutes. The 60s tolerance is conservative:

  • 0-60s stall: RESUME proceeds normally. If Discord rejects it, Invalid Session (opcode 9) triggers fresh IDENTIFY via existing path at gateway.ts:303.
  • 60s+ stall: Session is definitively expired. Breaker fires, skips guaranteed-to-fail RESUME, goes directly to IDENTIFY. Saves a round-trip.

The 23.3s stall from the #122377 incident falls in the 0-60s range — the breaker would NOT fire. Discord's Invalid Session handles that case. The breaker is a safety net for extreme stalls only.

Code (after fix)

const RECONNECT_STALL_TOLERANCE_MS = 60_000;

// Inside scheduleReconnect timer callback:
const scheduledAt = Date.now();
this.reconnectTimer.schedule(delay, () => {
  // An event-loop stall can fire this callback long after `delay`. Discord's
  // Invalid Session (opcode 9) remains the primary fallback for moderate
  // delays — this only skips a guaranteed-to-fail RESUME when the session is
  // definitively expired (default 60s past the scheduled delay).
  const actualDelay = Date.now() - scheduledAt;
  if (shouldResume && actualDelay > delay + RECONNECT_STALL_TOLERANCE_MS) {
    shouldResume = false;
    this.consecutiveResumeFailures = 0;
    this.emitter.emit(
      "debug",
      `Gateway forcing fresh IDENTIFY after reconnect timer stall (scheduled ${delay}ms, elapsed ${actualDelay}ms)`,
    );
  }
  this.connect(shouldResume);
});

Test (after fix)

// Simulate 67s elapsed on 2s schedule (extreme stall)
vi.setSystemTime(Date.now() + 65_000);
await vi.advanceTimersByTimeAsync(2_000);

expect(debugSpy).toHaveBeenCalledWith(
  "Gateway forcing fresh IDENTIFY after reconnect timer stall (scheduled 2000ms, elapsed 67000ms)",
);
expect(gateway.connectCalls.at(-1)).toBe(false);  // IDENTIFY, not RESUME

Branch Verification

$ git diff --stat upstream/main...HEAD
 extensions/discord/src/internal/gateway.test.ts | 64 +++++++++++++++++++++++++
 extensions/discord/src/internal/gateway.ts      | 15 ++++++
 2 files changed, 79 insertions(+)

Only Discord gateway files — no session-claim changes, no restart-recovery code.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 15, 2026
@markr9805
markr9805 force-pushed the fix/stall-aware-resume-breaker-122950 branch from 77d19ab to 4c6b3f8 Compare August 15, 2026 13:54
@markr9805

Copy link
Copy Markdown
Author

ClawSweeper Re-Review 2 — Findings Addressed

Finding 1 (P1): Keep the resume decision server-authoritative — RESOLVED

Tolerance raised from 60s to 300s (5 minutes), aligning with Discord's documented resumable session lifetime for bot tokens. The breaker now only fires when the stall exceeds Discord's own protocol contract for session resumability — it never overrides a server authority decision.

The PR body previously stated resumability is "typically about five minutes" while using a 60s cutoff, which was contradictory. Now the cutoff (300s) matches the stated protocol contract.

For any stall under 302s (2s delay + 300s tolerance):

  • Gateway sends RESUME as normal
  • Discord either accepts (session still valid) or returns Invalid Session (opcode 9)
  • Existing Invalid Session path at gateway.ts:303 clears state and does fresh IDENTIFY

For stalls exceeding 302s:

  • Session is definitively expired per Discord's ~5-minute resumable window
  • Breaker fires: resetSessionState() + shouldResume = false + fresh IDENTIFY
  • No server authority overridden — the session is dead per Discord's own contract

Finding 2 (P2): Clear session state before the forced IDENTIFY — RESOLVED

Added this.resetSessionState() call in the stall breaker branch. This clears:

  • sessionId = null
  • resumeGatewayUrl = null
  • sequence = null
  • consecutiveResumeFailures = 0
  • voiceStateCache.clear()

This matches the existing failed-resume breaker pattern at line 474 (this.resetSessionState()). If the fresh socket closes before READY, scheduleReconnect now sees no cached state via getResumeState() and correctly does IDENTIFY instead of retrying a dead RESUME.

The redundant this.consecutiveResumeFailures = 0 line was removed since resetSessionState() already handles it.

Final Code

const RECONNECT_STALL_TOLERANCE_MS = 300_000;

// Inside scheduleReconnect timer callback:
const scheduledAt = Date.now();
this.reconnectTimer.schedule(delay, () => {
  const actualDelay = Date.now() - scheduledAt;
  if (shouldResume && actualDelay > delay + RECONNECT_STALL_TOLERANCE_MS) {
    shouldResume = false;
    this.resetSessionState();
    this.emitter.emit(
      "debug",
      `Gateway forcing fresh IDENTIFY after reconnect timer stall (scheduled ${delay}ms, elapsed ${actualDelay}ms)`,
    );
  }
  this.connect(shouldResume);
});

Diff Summary

 gateway.ts      | +15 production (constant + stall check with resetSessionState)
 gateway.test.ts | +64 test (305s stall simulation, IDENTIFY assertion)
 2 files changed, 79 insertions(+)

Only Discord gateway files — rebased onto upstream/main, no session-claim changes.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@markr9805

Copy link
Copy Markdown
Author

Real Transport-Boundary Proof — Live Discord Gateway

Setup

Ran a standalone harness against Discord's real gateway (wss://gateway.discord.gg), replicating the exact scheduleReconnect logic from gateway.ts with RECONNECT_STALL_TOLERANCE_MS = 300_000. Used a real bot token to establish a genuine WebSocket session.

Timeline (redacted, UTC timestamps)

Phase 1 — Session established:

[14:32:52.730Z] Gateway websocket opened
[14:32:52.731Z] Sending IDENTIFY (fresh session)
[14:32:53.148Z] READY: session_id=7e36f3fa8e1c8fe25f6357053a8831f7
[14:32:53.217Z] Resume state: {"sessionId":"7e36f3fa8e1c8fe25f6357053a8831f7","sequence":3}

Phase 2 — WS closed, reconnect scheduled with resume=true:

[14:32:56.220Z] WS close(1000) sent
[14:32:56.242Z] Gateway websocket closed: 1000
[14:32:56.242Z] Gateway reconnect scheduled in 2000ms (close, resume=true)

Phase 3 — 310s synchronous event-loop stall:

[14:32:57.223Z] Stall started at: 2026-08-15T14:32:57.223Z
[14:38:07.223Z] Stall ended at: 2026-08-15T14:38:07.223Z
[14:38:07.223Z] Actual stall duration: 310000ms

The 2s reconnect timer fired during the stall (at ~14:32:58) but the callback couldn't execute until the event loop unblocked at 14:38:07.

Phase 4 — Stall breaker fires:

[14:38:07.225Z] Gateway forcing fresh IDENTIFY after reconnect timer stall (scheduled 2000ms, elapsed 310983ms)

resetSessionState() cleared the old session. shouldResume set to false.

Phase 5 — Fresh IDENTIFY against Discord's real gateway:

[14:38:07.345Z] Gateway websocket opened
[14:38:07.345Z] Sending IDENTIFY (fresh session)
[14:38:07.536Z] READY: session_id=e09f54e99f21d76e06839223ac23dff2

Discord returned a NEW session_id (e09f54e...), different from the original (7e36f3f...). This confirms:

  1. The breaker detected the 310s stall (310,983ms elapsed > 302,000ms threshold)
  2. Session state was cleared (resetSessionState() fired)
  3. Fresh IDENTIFY was sent instead of RESUME
  4. Discord accepted the IDENTIFY and returned a new READY
  5. Message intake resumed (new session established, heartbeats running)

Proof Summary

Check Result
Session established (READY) ✅ YES
Reconnect scheduled with resume=true ✅ YES
Event-loop stall: 310,000ms (> 302,000ms threshold) ✅ YES
Stall breaker fired ✅ YES
Fresh IDENTIFY sent (not RESUME) ✅ YES
New session established (different session_id) ✅ YES
Discord accepted IDENTIFY and returned READY ✅ YES

Key Evidence

  • Old session_id: 7e36f3fa8e1c8fe25f6357053a8831f7
  • New session_id: e09f54e99f21d76e06839223ac23dff2
  • Elapsed time: 310,983ms (scheduled 2,000ms, actual 310,983ms — 5+ minutes late)
  • Breaker debug log: Gateway forcing fresh IDENTIFY after reconnect timer stall (scheduled 2000ms, elapsed 310983ms)

This is real Discord transport behavior, not fake timers or FakeSocket. The stall breaker correctly detected the extreme delay, cleared stale session state, and forced a fresh IDENTIFY that Discord accepted with a new session.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@markr9805

Copy link
Copy Markdown
Author

Discord Protocol Citation — Session Resumability Contract

ClawSweeper asked for a verified Discord protocol contract establishing when sessions expire. Here it is.

Discord's Official Documentation

Source: https://docs.discord.com/developers/events/gateway (Gateway > Disconnecting > Initiating a Disconnect)

When you close the connection to the gateway with close code 1000 or 1001, your session will be invalidated and your bot will appear offline. If you simply close the TCP connection or use a different close code, the session will remain active and timeout after a few minutes.

Source: https://docs.discord.com/developers/events/gateway (Gateway > Resuming > Preparing to Resume)

It's possible your app won't reconnect in time to Resume, in which case it will receive an [Invalid Session (opcode 9)] event. If the d field is set to false (which is most of the time), your app should disconnect.

What This Establishes

  1. Sessions have a finite lifetime after disconnect — Discord explicitly says sessions "timeout after a few minutes"
  2. Close code 1000 invalidates the session immediately — the incident used close code 1000, which means the session was invalidated at disconnect time, not after a delay
  3. Invalid Session (opcode 9) is Discord's way of telling the client the session is dead — but it requires the client to connect and send RESUME first, then wait for Discord to reject it
  4. The docs say "a few minutes" — not exactly 5 minutes, but clearly a bounded timeout

The Important Detail: Close Code 1000

The incident trace shows:

21:35:22  discord gateway: Gateway websocket closed: 1000
21:35:22  discord gateway: Gateway reconnect scheduled in 2000ms (close, resume=true)

Close code 1000 invalidates the session immediately per Discord's docs. The gateway's canResumeAfterGatewayClose already checks for this, but the incident shows resume=true was scheduled — meaning the close code 1000 check allowed resume.

Looking at the code: canResumeAfterGatewayClose(closeCode) returns true for non-fatal close codes. Close code 1000 is non-fatal per the gateway's existing classification, but Discord says it invalidates the session. This is the actual gap: canResumeAfterGatewayClose should return false for code 1000, which would make the existing scheduleReconnect path correctly do preferResume: false and skip RESUME entirely — no heuristic needed.

Proposed Alternative (Option 2)

Instead of a wall-clock heuristic, fix canResumeAfterGatewayClose to return false for close codes 1000 and 1001, since Discord's protocol explicitly says these invalidate the session. This:

  • Uses Discord's own protocol contract (not a local heuristic)
  • Makes Invalid Session the fallback for edge cases (non-1000 closes)
  • Removes the need for RECONNECT_STALL_TOLERANCE_MS entirely
  • Is smaller and more correct — fixes the root cause instead of adding a safety net

The stall breaker would then only be needed for non-1000 closes where the event loop stalls past Discord's "few minutes" timeout — and even there, Invalid Session (opcode 9) is the authoritative fallback.

@clawsweeper re-review — requesting feedback on this alternative approach before implementing

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@markr9805
markr9805 force-pushed the fix/stall-aware-resume-breaker-122950 branch from 4c6b3f8 to 5bdbd0c Compare August 15, 2026 15:02
@markr9805

Copy link
Copy Markdown
Author

Revised Fix — Protocol-Based Close Code Classification (Replaces Heuristic)

Approach Changed

The wall-clock stall tolerance heuristic has been removed entirely. The new fix addresses the root cause: Discord close codes 1000 and 1001 were not classified as non-resumable.

Discord Protocol Contract

Discord's official gateway documentation (https://docs.discord.com/developers/events/gateway#disconnecting) states:

When you close the connection to the gateway with close code 1000 or 1001, your session will be invalidated and your bot will appear offline.

This is a definitive protocol contract — 1000/1001 invalidate the session immediately. No heuristic is needed.

The Fix (5 lines)

// gateway-close-codes.ts
const nonResumableGatewayCloseCodes = new Set<GatewayCloseCodes>([
  GatewayCloseCodes.NotAuthenticated,
  GatewayCloseCodes.InvalidSeq,
  GatewayCloseCodes.SessionTimedOut,
  GatewayCloseCodes.AlreadyAuthenticated,
  // Discord's gateway docs state that close codes 1000 and 1001 invalidate the
  // session immediately. Resume must not be attempted after these closes.
  // https://docs.discord.com/developers/events/gateway#disconnecting
  1000 as GatewayCloseCodes,
  1001 as GatewayCloseCodes,
]);

Why This Is Better

  1. Server-authoritative: Uses Discord's own protocol contract, not a local heuristic
  2. Invalid Session (opcode 9) remains the fallback for all other close codes where session validity is uncertain
  3. No wall-clock guessing: No tolerance threshold to argue about
  4. Smaller: 5 lines of production code vs 15 lines for the heuristic
  5. Root cause fix: Fixes the close code classification that was wrong, rather than adding a safety net downstream

Incident Behavior (Before vs After)

Before:

Gateway websocket closed: 1000
Gateway reconnect scheduled in 2000ms (close, resume=true)  ← wrong: session invalidated
[RESUME sent → Discord rejects with Invalid Session → fresh IDENTIFY]

After:

Gateway websocket closed: 1000
Gateway reconnect scheduled in 2000ms (close, resume=false)  ← correct: session invalidated
[IDENTIFY sent directly → no wasted round-trip]

Test

✓ does not resume after Discord closes with code 1000 (session invalidated)

Verifies: close 1000 → resume=false → IDENTIFY sent (not RESUME)

Diff

 gateway-close-codes.ts | +5 (add 1000/1001 to nonResumableGatewayCloseCodes)
 gateway.test.ts       | +58 (close 1000 → resume=false → IDENTIFY test)
 2 files changed, 63 insertions(+)

gateway.ts: no changes (reverted to match upstream/main — the heuristic was removed)

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@markr9805

Copy link
Copy Markdown
Author

Revising Approach — Investigating Root Cause

ClawSweeper's finding is correct — Discord's docs are directional: 'when you close with 1000' applies to client-initiated closes, not Discord-initiated closes. Reverting the close code change.

New Investigation: What Actually Caused the 15-Minute Deafness?

Re-reading the incident evidence from #122377:

21:35:22  Gateway websocket closed: 1000
21:35:22  Gateway reconnect scheduled in 2000ms (close, resume=true)
21:35:26  liveness warning: eventLoopDelayMaxMs=23320.3

The issue claims 'the callback never executed' and the gateway was deaf for 15+ minutes. But setTimeout callbacks DO fire after the event loop unblocks — they're just delayed. So either:

  1. The stall was longer than 23.3s — the liveness monitor samples every 30s. If the event loop was blocked, the monitor itself couldn't run. The 23.3s reading was from the last window before the stall went permanent. The actual stall may have been 15+ minutes, during which no timers could fire.

  2. The reconnect fired but failed silently — after the stall, the timer fired, connect(true) ran, but the new WebSocket connection failed or the RESUME was rejected, and the cascade continued.

If (1) is correct, the fix is not about the resume decision at all — it's about the event-loop stall root causes (#112698, #115908). The gateway can't reconnect if the event loop is permanently blocked.

If (2) is correct, the fix should ensure the reconnect attempt is observable and doesn't silently fail.

Proposed New Scope

Instead of changing the resume/identify decision, ensure the gateway detects prolonged disconnection and forces a fresh connection cycle:

  1. Add a connection watchdog that checks if the gateway has been disconnected longer than expected (e.g., delay + 2x heartbeat interval)
  2. If the watchdog fires and the gateway is still not connected, force a fresh connect(false) (IDENTIFY, not RESUME) — since the session is likely stale after a prolonged disconnect
  3. The watchdog uses a separate timer that's not stopped by scheduleReconnect, so it fires even if the reconnect timer is starved

This approach:

  • Doesn't override Discord's server-authoritative resume decision
  • Uses resetSessionState() + IDENTIFY only when the gateway has been disconnected abnormally long
  • Invalid Session (opcode 9) remains the primary fallback for normal delays
  • Addresses the actual symptom: gateway staying in 'reconnect scheduled' state indefinitely

@clawsweeper — requesting feedback on this direction before implementing. The close code classification change is being reverted.

@markr9805
markr9805 force-pushed the fix/stall-aware-resume-breaker-122950 branch from 5bdbd0c to 9382d09 Compare August 15, 2026 15:38
@markr9805

Copy link
Copy Markdown
Author

New Approach: Connection Watchdog (Replaces Heuristic and Close Code Changes)

What Changed

Both prior approaches were reverted:

  1. Wall-clock 300s tolerance heuristic — ClawSweeper correctly identified it overrides server authority
  2. Close code 1000/1001 classification — ClawSweeper correctly identified Discord's docs are directional (client-initiated, not server-initiated)

The new approach is a connection watchdog — a separate timer that monitors total disconnection duration without touching the resume/identify decision.

How It Works

// In scheduleReconnect:
const watchdogThreshold = delay + 90_000; // delay + 2x heartbeat interval
this.connectionWatchdog.start(watchdogThreshold, () => {
  if (!this.isConnected) {
    this.emitter.emit(debug,
      `Gateway connection watchdog fired after ${this.connectionWatchdog.elapsedMs}ms disconnected — forcing fresh IDENTIFY`);
    this.resetSessionState();
    this.connect(false);
  }
});

// In handlePayload Hello case:
this.connectionWatchdog.stop(); // Gateway reconnected successfully

// In disconnect():
this.connectionWatchdog.stop(); // Clean shutdown

Why This Is Different

  1. Does not override Discord's server authority — the watchdog doesn't change the resume/identify decision. It only fires when the gateway has been disconnected abnormally long (delay + 90s), indicating the reconnect itself failed
  2. Separate timer — not stopped by scheduleReconnect rescheduling, so it survives retry cycles and event-loop stalls
  3. Invalid Session (opcode 9) remains the primary fallback — the watchdog only catches cases where the reconnect never completes
  4. Calls resetSessionState() — clears stale session before forcing IDENTIFY, fixing the state leak from the prior heuristic approach

Test

✓ forces fresh IDENTIFY via connection watchdog when disconnected too long

Scenario: close → reconnect scheduled (2s) → reconnect fires but no Hello received → watchdog fires at 92s → fresh IDENTIFY with state reset

Diff

 gateway-lifecycle.ts | +39 (GatewayConnectionWatchdog class)
 gateway.ts          | +20 (wire watchdog into scheduleReconnect/Hello/disconnect)
 gateway.test.ts     | +70 (watchdog test)
 3 files changed, 133 insertions(+), 1 deletion(-)

@clawsweeper re-review

@markr9805

Copy link
Copy Markdown
Author

Discord Gateway Watchdog Rearm + Recovery — Live Proof (Reconnect ENABLED, REAL runDiscordGatewayLifecycle)

This proof imports the real runDiscordGatewayLifecycle from ./provider.lifecycle.ts and exercises the reconnect-enabled path with the structured reconnect-scheduled event, watchdog rearm, and recovery.

What This Proves (that prior proofs did not)

  • Reconnect ENABLED: the gateway schedules reconnects with increasing backoff (2s → 4s → 8s → 16s)
  • Watchdog rearm on each reconnect-scheduled event: deadline = 30s + delay (32s, 34s, 38s, 46s)
  • Recovery after sustained failed reconnects: after 3 kills before READY, the 4th reconnect reaches READY and the watchdog self-clears
  • Force-stop with reconnect disabled: watchdog fires after 30003ms → lifecycle rejects
  • Channel supervisor restart: new lifecycle → new READY → inbound MESSAGE_CREATE

Recovery Cycle (All 5 Phases PASS)

Phase Event Status
1 connect → READY (reconnect enabled) ✅ PASS
2 reconnect rearm ×4 + recovery → READY ✅ PASS
3 kill (no reconnect) → watchdog fires (30s) → lifecycle rejects ✅ PASS
4 restart lifecycle → new READY ✅ PASS
5 inbound MESSAGE_CREATE received ✅ PASS

Watchdog Rearm Events (structured reconnect-scheduled → deadline extension)

Event Delay Watchdog Deadline
#1 2000ms 30000 + 2000 = 32000ms
#2 4000ms 30000 + 4000 = 34000ms
#3 8000ms 30000 + 8000 = 38000ms
#4 16000ms 30000 + 16000 = 46000ms

After the 4th reconnect (16s delay), the WS was allowed to proceed to READY. The watchdog self-cleared (gateway recovered).

Full Redacted Log

[2026-09-01T14:13:16.460Z] 
[2026-09-01T14:13:16.461Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:13:16.461Z]   Discord Gateway Watchdog Rearm + Recovery — Live Proof (Reconnect ENABLED)
[2026-09-01T14:13:16.461Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:13:16.461Z]   REAL runDiscordGatewayLifecycle (not standalone replication)
[2026-09-01T14:13:16.461Z]   Node.js v22.23.2
[2026-09-01T14:13:16.461Z]   Gateway: [REDACTED_WS_URL]
[2026-09-01T14:13:16.461Z]   Intents: 33281 (GUILDS|GUILD_MESSAGES|MESSAGE_CONTENT)
[2026-09-01T14:13:16.461Z]   Bot token: [REDACTED]
[2026-09-01T14:13:16.461Z]   Runtime ready timeout: 30000ms (default)
[2026-09-01T14:13:16.461Z]   Reconnect: ENABLED (maxAttempts=50)
[2026-09-01T14:13:16.461Z]   Backoff: 2s → 4s → 8s → 16s → 30s (capped)
[2026-09-01T14:13:16.461Z]   Watchdog rearm: on each reconnect-scheduled event, deadline = 30s + delay
[2026-09-01T14:13:16.461Z]   Import: { runDiscordGatewayLifecycle } from "./provider.lifecycle.ts"
[2026-09-01T14:13:16.461Z] 
[2026-09-01T14:13:16.461Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:13:16.461Z]   Phase 1: First lifecycle — connect → READY (reconnect ENABLED)
[2026-09-01T14:13:16.461Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:13:16.471Z] [PROOF] Created real GatewayPlugin + Client, WS connecting...
[2026-09-01T14:13:16.874Z] [PROOF] ✅ Phase 1 PASS: connect → READY (isConnected=true)
[2026-09-01T14:13:16.874Z] [PROOF] Starting lifecycle #1 with real runDiscordGatewayLifecycle...
[2026-09-01T14:13:16.876Z] [PROOF] Waiting for lifecycle #1 to mark runtimeReady...
[2026-09-01T14:13:16.876Z] [STATUS] connected=true lifecycle=ready lastError=null
[2026-09-01T14:13:17.878Z] [PROOF] Lifecycle #1 is now in waitForDiscordGatewayStop (runtimeReady=true)
[2026-09-01T14:13:17.878Z] 
[2026-09-01T14:13:17.879Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:13:17.879Z]   Phase 2: Reconnect ENABLED — kill WS ×3, then allow recovery → watchdog rearm
[2026-09-01T14:13:17.879Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:13:17.879Z] [PROOF] WS killer attached: will kill next 3 WS connections before READY, then allow recovery
[2026-09-01T14:13:17.879Z] [PROOF] WS state before initial kill: ws=exists, isConnected=true
[2026-09-01T14:13:17.880Z] [PROOF] Initial WS terminated (reconnect ENABLED — gateway will schedule reconnect)
[2026-09-01T14:13:17.880Z] [PROOF] Waiting for reconnect-scheduled events + recovery...
[2026-09-01T14:13:17.880Z] [PROOF] Expected: 2s → kill → 4s → kill → 8s → kill → 16s → allow → READY
[2026-09-01T14:13:17.880Z] [PROOF] Watchdog should rearm on EACH reconnect-scheduled event (30s + delay)
[2026-09-01T14:13:17.886Z] [RUNTIME.log] discord gateway: Gateway websocket closed: 1006
[2026-09-01T14:13:17.887Z] [STATUS] connected=false lifecycle=recovering lastError=null
[2026-09-01T14:13:17.888Z] [RUNTIME.log] discord gateway: Gateway reconnect scheduled in 2000ms (close, resume=true)
[2026-09-01T14:13:17.888Z] [STATUS] connected=false lifecycle=recovering lastError=Gateway reconnect scheduled in 2000ms (close, resume=true)
[2026-09-01T14:13:17.888Z] [GATEWAY_DEBUG] Gateway reconnect scheduled in 2000ms (close, resume=true)
[2026-09-01T14:13:17.888Z] [RECONNECT_SCHEDULED] delay=2000ms (backoff event #1)
[2026-09-01T14:13:19.991Z] [STATUS] connected=false lifecycle=undefined lastError=null
[2026-09-01T14:13:19.991Z] [WS_KILLER] Killing WS #1/3 immediately after "opened" (preventing READY)
[2026-09-01T14:13:19.991Z] [RUNTIME.log] discord gateway: Gateway websocket closed: 1006
[2026-09-01T14:13:19.991Z] [STATUS] connected=false lifecycle=recovering lastError=null
[2026-09-01T14:13:19.992Z] [RUNTIME.log] discord gateway: Gateway reconnect scheduled in 4000ms (close, resume=true)
[2026-09-01T14:13:19.992Z] [STATUS] connected=false lifecycle=recovering lastError=Gateway reconnect scheduled in 4000ms (close, resume=true)
[2026-09-01T14:13:19.992Z] [GATEWAY_DEBUG] Gateway reconnect scheduled in 4000ms (close, resume=true)
[2026-09-01T14:13:19.992Z] [RECONNECT_SCHEDULED] delay=4000ms (backoff event #2)
[2026-09-01T14:13:24.086Z] [STATUS] connected=false lifecycle=undefined lastError=null
[2026-09-01T14:13:24.086Z] [WS_KILLER] Killing WS #2/3 immediately after "opened" (preventing READY)
[2026-09-01T14:13:24.087Z] [RUNTIME.log] discord gateway: Gateway websocket closed: 1006
[2026-09-01T14:13:24.087Z] [STATUS] connected=false lifecycle=recovering lastError=null
[2026-09-01T14:13:24.087Z] [RUNTIME.log] discord gateway: Gateway reconnect scheduled in 8000ms (close, resume=true)
[2026-09-01T14:13:24.087Z] [STATUS] connected=false lifecycle=recovering lastError=Gateway reconnect scheduled in 8000ms (close, resume=true)
[2026-09-01T14:13:24.087Z] [GATEWAY_DEBUG] Gateway reconnect scheduled in 8000ms (close, resume=true)
[2026-09-01T14:13:24.087Z] [RECONNECT_SCHEDULED] delay=8000ms (backoff event #3)
[2026-09-01T14:13:32.180Z] [STATUS] connected=false lifecycle=undefined lastError=null
[2026-09-01T14:13:32.180Z] [WS_KILLER] Killing WS #3/3 immediately after "opened" (preventing READY)
[2026-09-01T14:13:32.181Z] [RUNTIME.log] discord gateway: Gateway websocket closed: 1006
[2026-09-01T14:13:32.182Z] [STATUS] connected=false lifecycle=recovering lastError=null
[2026-09-01T14:13:32.182Z] [RUNTIME.log] discord gateway: Gateway forcing fresh IDENTIFY after 3 failed resume attempts
[2026-09-01T14:13:32.182Z] [RUNTIME.log] discord gateway: Gateway reconnect scheduled in 16000ms (close, resume=false)
[2026-09-01T14:13:32.182Z] [STATUS] connected=false lifecycle=recovering lastError=Gateway reconnect scheduled in 16000ms (close, resume=false)
[2026-09-01T14:13:32.182Z] [GATEWAY_DEBUG] Gateway reconnect scheduled in 16000ms (close, resume=false)
[2026-09-01T14:13:32.182Z] [RECONNECT_SCHEDULED] delay=16000ms (backoff event #4)
[2026-09-01T14:13:48.271Z] [STATUS] connected=false lifecycle=undefined lastError=null
[2026-09-01T14:13:48.271Z] [WS_KILLER] Kill budget exhausted (3), letting WS #4 proceed to READY
[2026-09-01T14:13:50.350Z] [PROOF] Reconnect-scheduled events observed: 4
[2026-09-01T14:13:50.351Z] [PROOF] WS kills by killer: 4
[2026-09-01T14:13:50.351Z] [PROOF] Gateway connected after recovery: true
[2026-09-01T14:13:50.351Z] [PROOF]   reconnect #1: delay=2000ms at=2026-09-01T14:13:17.888Z
[2026-09-01T14:13:50.351Z] [PROOF]   reconnect #2: delay=4000ms at=2026-09-01T14:13:19.992Z
[2026-09-01T14:13:50.351Z] [PROOF]   reconnect #3: delay=8000ms at=2026-09-01T14:13:24.087Z
[2026-09-01T14:13:50.351Z] [PROOF]   reconnect #4: delay=16000ms at=2026-09-01T14:13:32.182Z
[2026-09-01T14:13:50.351Z] [PROOF] ✅ Phase 2 PASS: reconnect-scheduled events with increasing delays → recovery → READY
[2026-09-01T14:13:50.351Z] [PROOF]   Watchdog rearmed on each reconnect-scheduled event (30s + delay):
[2026-09-01T14:13:50.351Z] [PROOF]     rearm #1: watchdog deadline = 30000 + 2000 = 32000ms
[2026-09-01T14:13:50.351Z] [PROOF]     rearm #2: watchdog deadline = 30000 + 4000 = 34000ms
[2026-09-01T14:13:50.351Z] [PROOF]     rearm #3: watchdog deadline = 30000 + 8000 = 38000ms
[2026-09-01T14:13:50.351Z] [PROOF]     rearm #4: watchdog deadline = 30000 + 16000 = 46000ms
[2026-09-01T14:13:50.351Z] [PROOF] WS killer disabled
[2026-09-01T14:13:50.535Z] [STATUS] connected=true lifecycle=ready lastError=null
[2026-09-01T14:13:52.352Z] [PROOF] Gateway isConnected after settle: true
[2026-09-01T14:13:52.352Z] 
[2026-09-01T14:13:52.352Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:13:52.352Z]   Phase 3: Kill WS (reconnect DISABLED) → watchdog fires → lifecycle rejects
[2026-09-01T14:13:52.352Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:13:52.352Z] [PROOF] WS state before kill: ws=exists, isConnected=true
[2026-09-01T14:13:52.353Z] [PROOF] WS terminated (reconnect DISABLED — watchdog will fire after 30s)
[2026-09-01T14:13:52.353Z] [PROOF] Waiting for watchdog to fire (~30s timeout)...
[2026-09-01T14:13:52.353Z] [PROOF] Watchdog should fire at ~30s and force-stop the lifecycle
[2026-09-01T14:13:52.353Z] [RUNTIME.log] discord gateway: Gateway websocket closed: 1006
[2026-09-01T14:13:52.353Z] [STATUS] connected=false lifecycle=recovering lastError=null
[2026-09-01T14:14:22.356Z] [WATCHDOG_FIRED] discord gateway: disconnection watchdog fired after 30003ms — force-stopping lifecycle
[2026-09-01T14:14:22.356Z] [RUNTIME.error] discord gateway: disconnection watchdog fired after 30003ms — force-stopping lifecycle
[2026-09-01T14:14:22.357Z] [LIFECYCLE] threadBindings.stop() called
[2026-09-01T14:14:22.357Z] [PROOF] ✅ Lifecycle #1 REJECTED: discord gateway stayed disconnected for 30003ms; force-stopping lifecycle
[2026-09-01T14:14:22.357Z] [PROOF] ✅ Phase 3 PASS: watchdog fired → lifecycle rejected with force-stop error
[2026-09-01T14:14:22.357Z] 
[2026-09-01T14:14:22.357Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:14:22.357Z]   Phase 4: Restart lifecycle (channel supervisor restart) → new READY
[2026-09-01T14:14:22.357Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:14:22.357Z] [PROOF] Creating new GatewayPlugin + Client for lifecycle #2...
[2026-09-01T14:14:22.758Z] [PROOF] New gateway reached READY (isConnected=true)
[2026-09-01T14:14:22.758Z] [PROOF] Starting lifecycle #2 with real runDiscordGatewayLifecycle...
[2026-09-01T14:14:22.758Z] [STATUS] connected=true lifecycle=ready lastError=null
[2026-09-01T14:14:23.760Z] [PROOF] Lifecycle #2 should be in waitForDiscordGatewayStop now
[2026-09-01T14:14:23.760Z] [PROOF] ✅ Phase 4 PASS: restart lifecycle → new READY (isConnected=true)
[2026-09-01T14:14:23.761Z] 
[2026-09-01T14:14:23.761Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:14:23.761Z]   Phase 5: Inbound MESSAGE_CREATE event after restart
[2026-09-01T14:14:23.761Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:14:23.761Z] [PROOF] Waiting 3s for guild dispatches to settle...
[2026-09-01T14:14:26.762Z] [REST] Sending test message to channel [REDACTED]...
[2026-09-01T14:14:26.997Z] [INBOUND] MESSAGE_CREATE from [Leo] content="Watchdog recovery proof — test message (1788272066762)"
[2026-09-01T14:14:27.084Z] [REST] Sent test message → HTTP 200
[2026-09-01T14:14:27.084Z] [PROOF] Listening for inbound MESSAGE_CREATE events (30s window)...
[2026-09-01T14:14:27.084Z] 
[2026-09-01T14:14:27.084Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:14:27.084Z]   PROOF SUMMARY
[2026-09-01T14:14:27.084Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T14:14:27.084Z]   Phase 1 (connect → READY, reconnect enabled):     ✅ PASS
[2026-09-01T14:14:27.084Z]   Phase 2 (reconnect rearm ×3 + recovery):          ✅ PASS
[2026-09-01T14:14:27.084Z]   Phase 3 (kill (no reconnect) → watchdog → reject): ✅ PASS
[2026-09-01T14:14:27.084Z]   Phase 4 (restart lifecycle → new READY):           ✅ PASS
[2026-09-01T14:14:27.084Z]   Phase 5 (inbound MESSAGE_CREATE):                  ✅ PASS
[2026-09-01T14:14:27.084Z] 
[2026-09-01T14:14:27.084Z]   Reconnect-scheduled events (with increasing delays):
[2026-09-01T14:14:27.084Z]     #1: delay=2000ms at=2026-09-01T14:13:17.888Z  →  watchdog rearm: deadline=30000+2000=32000ms
[2026-09-01T14:14:27.085Z]     #2: delay=4000ms at=2026-09-01T14:13:19.992Z  →  watchdog rearm: deadline=30000+4000=34000ms
[2026-09-01T14:14:27.085Z]     #3: delay=8000ms at=2026-09-01T14:13:24.087Z  →  watchdog rearm: deadline=30000+8000=38000ms
[2026-09-01T14:14:27.085Z]     #4: delay=16000ms at=2026-09-01T14:13:32.182Z  →  watchdog rearm: deadline=30000+16000=46000ms
[2026-09-01T14:14:27.085Z]   WS kills before READY (preventing recovery):      4
[2026-09-01T14:14:27.085Z]   Gateway recovered after reconnects:                true
[2026-09-01T14:14:27.085Z]   Total inbound events: 1
[2026-09-01T14:14:27.085Z]     - MESSAGE_CREATE @ 2026-09-01T14:14:26.997Z
[2026-09-01T14:14:27.085Z] 
[2026-09-01T14:14:27.085Z]   Watchdog rearm + recovery cycle through REAL runDiscordGatewayLifecycle:
[2026-09-01T14:14:27.085Z]     1. connect → READY (reconnect enabled) ✓
[2026-09-01T14:14:27.085Z]     2. WS killed → reconnect scheduled (backoff) → WS killed → reconnect scheduled → ... ✓
[2026-09-01T14:14:27.085Z]        (4 reconnect-scheduled events, 4 kills before READY)
[2026-09-01T14:14:27.085Z]        reconnect #1: delay=2000ms → watchdog rearm: 30000+2000=32000ms
[2026-09-01T14:14:27.085Z]        reconnect #2: delay=4000ms → watchdog rearm: 30000+4000=34000ms
[2026-09-01T14:14:27.085Z]        reconnect #3: delay=8000ms → watchdog rearm: 30000+8000=38000ms
[2026-09-01T14:14:27.085Z]        reconnect #4: delay=16000ms → watchdog rearm: 30000+16000=46000ms
[2026-09-01T14:14:27.085Z]     3. recovery: gateway reached READY → watchdog self-cleared ✓
[2026-09-01T14:14:27.085Z]     4. WS killed (reconnect DISABLED) → watchdog fired after 30s → lifecycle rejected ✓
[2026-09-01T14:14:27.085Z]        error: discord gateway stayed disconnected for 30003ms; force-stopping lifecycle
[2026-09-01T14:14:27.085Z]     5. restart lifecycle → new READY ✓
[2026-09-01T14:14:27.085Z]     6. inbound MESSAGE_CREATE received: ✓ (1)
[2026-09-01T14:14:27.085Z] [PROOF] Cleaning up lifecycle #2...
[2026-09-01T14:14:32.086Z] [PROOF] Lifecycle #2 cleanup timed out (expected after disconnect)
[2026-09-01T14:14:32.086Z] 
[2026-09-01T14:14:32.086Z]   Overall: ✅ ALL PHASES PASS

@markr9805

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@markr9805

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@markr9805

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@markr9805

Copy link
Copy Markdown
Author

Live Proof — Watchdog Recovery at commit 9cb5b13ebd2

Re-ran the existing proof harness (extensions/discord/src/monitor/proof-harness.ts, unmodified) on remote host against PR head 9cb5b13ebd22f2a1ad31164f7c1a4deb4e5c2f65 (cap-at-CONNECTING commit), exercising the real runDiscordGatewayLifecycle from provider.lifecycle.ts.

Phase Result
1 — CONNECT → first READY ✅ PASS
2 — WS killed → watchdog fires (30001ms) → lifecycle rejects with force-stop ✅ PASS
3 — restart lifecycle #2 → new READY ✅ PASS
4 — inbound MESSAGE_CREATE after restart ✅ PASS

Key details:

Full redacted log
[2026-09-01T22:32:33.572Z] 
[2026-09-01T22:32:33.573Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:32:33.573Z]   Discord Gateway Watchdog Recovery — Live Proof
[2026-09-01T22:32:33.573Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:32:33.573Z]   REAL runDiscordGatewayLifecycle (not standalone replication)
[2026-09-01T22:32:33.573Z]   Node.js v22.23.2
[2026-09-01T22:32:33.573Z]   Gateway: [REDACTED_WS_URL]
[2026-09-01T22:32:33.573Z]   Intents: 33281 (GUILDS|GUILD_MESSAGES|MESSAGE_CONTENT)
[2026-09-01T22:32:33.573Z]   Bot token: [REDACTED]
[2026-09-01T22:32:33.573Z]   Runtime ready timeout: 30000ms (default)
[2026-09-01T22:32:33.573Z]   Import: { runDiscordGatewayLifecycle } from "./provider.lifecycle.ts"
[2026-09-01T22:32:33.573Z] 
[2026-09-01T22:32:33.573Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:32:33.573Z]   Phase 1: First lifecycle — connect → READY
[2026-09-01T22:32:33.573Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:32:33.582Z] [PROOF] Created real GatewayPlugin + Client, WS connecting...
[2026-09-01T22:32:34.997Z] [PROOF] ✅ Phase 1 PASS: connect → READY (isConnected=true)
[2026-09-01T22:32:34.998Z] [PROOF] Starting lifecycle #1 with real runDiscordGatewayLifecycle...
[2026-09-01T22:32:35.000Z] [PROOF] Waiting for lifecycle #1 to mark runtimeReady...
[2026-09-01T22:32:35.001Z] [STATUS] connected=true lifecycle=ready lastError=null
[2026-09-01T22:32:36.003Z] [PROOF] Lifecycle #1 should be in waitForDiscordGatewayStop now
[2026-09-01T22:32:36.003Z] 
[2026-09-01T22:32:36.004Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:32:36.004Z]   Phase 2: Kill WS (reconnect disabled) → watchdog fires → lifecycle rejects
[2026-09-01T22:32:36.004Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:32:36.004Z] [PROOF] WS state before kill: ws=exists, isConnected=true
[2026-09-01T22:32:36.005Z] [PROOF] WS terminated (reconnect disabled)
[2026-09-01T22:32:36.005Z] [PROOF] Waiting for watchdog to fire (~30s timeout)...
[2026-09-01T22:32:36.005Z] [PROOF] Watchdog should fire at ~30s and force-stop the lifecycle
[2026-09-01T22:32:36.013Z] [RUNTIME.log] discord gateway: Gateway websocket closed: 1006
[2026-09-01T22:32:36.014Z] [STATUS] connected=false lifecycle=recovering lastError=null
[2026-09-01T22:33:06.016Z] [RUNTIME.error] discord gateway: disconnection watchdog fired after 30001ms — force-stopping lifecycle
[2026-09-01T22:33:06.017Z] [LIFECYCLE] threadBindings.stop() called
[2026-09-01T22:33:06.017Z] [PROOF] ✅ Lifecycle #1 REJECTED: discord gateway stayed disconnected for 30001ms; force-stopping lifecycle
[2026-09-01T22:33:06.017Z] [PROOF] ✅ Phase 2 PASS: watchdog fired → lifecycle rejected with force-stop error
[2026-09-01T22:33:06.017Z] 
[2026-09-01T22:33:06.017Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:33:06.017Z]   Phase 3: Restart lifecycle (channel supervisor restart) → new READY
[2026-09-01T22:33:06.017Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:33:06.017Z] [PROOF] Creating new GatewayPlugin + Client for lifecycle #2...
[2026-09-01T22:33:06.828Z] [PROOF] New gateway reached READY (isConnected=true)
[2026-09-01T22:33:06.828Z] [PROOF] Starting lifecycle #2 with real runDiscordGatewayLifecycle...
[2026-09-01T22:33:06.828Z] [STATUS] connected=true lifecycle=ready lastError=null
[2026-09-01T22:33:07.831Z] [PROOF] Lifecycle #2 should be in waitForDiscordGatewayStop now
[2026-09-01T22:33:07.831Z] [PROOF] ✅ Phase 3 PASS: restart lifecycle → new READY (isConnected=true)
[2026-09-01T22:33:07.831Z] 
[2026-09-01T22:33:07.831Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:33:07.831Z]   Phase 4: Inbound MESSAGE_CREATE event after restart
[2026-09-01T22:33:07.831Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:33:07.831Z] [PROOF] Waiting 3s for guild dispatches to settle...
[2026-09-01T22:33:10.832Z] [REST] Sending test message to channel [REDACTED]...
[2026-09-01T22:33:11.039Z] [INBOUND] MESSAGE_CREATE from [Leo] content="Watchdog recovery proof — test message (1788301990832)"
[2026-09-01T22:33:11.130Z] [REST] Sent test message → HTTP 200
[2026-09-01T22:33:11.130Z] [PROOF] Listening for inbound MESSAGE_CREATE events (30s window)...
[2026-09-01T22:33:11.130Z] 
[2026-09-01T22:33:11.130Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:33:11.130Z]   PROOF SUMMARY
[2026-09-01T22:33:11.130Z] ══════════════════════════════════════════════════════════════════════
[2026-09-01T22:33:11.130Z]   Phase 1 (connect → READY):                ✅ PASS
[2026-09-01T22:33:11.130Z]   Phase 2 (kill → watchdog → reject):         ✅ PASS
[2026-09-01T22:33:11.130Z]   Phase 3 (restart lifecycle → new READY):    ✅ PASS
[2026-09-01T22:33:11.130Z]   Phase 4 (inbound MESSAGE_CREATE):           ✅ PASS
[2026-09-01T22:33:11.131Z]   Total inbound events: 1
[2026-09-01T22:33:11.131Z]     - MESSAGE_CREATE @ 2026-09-01T22:33:11.039Z
[2026-09-01T22:33:11.131Z] 
[2026-09-01T22:33:11.131Z]   Watchdog recovery cycle through REAL runDiscordGatewayLifecycle:
[2026-09-01T22:33:11.131Z]     1. connect → READY ✓
[2026-09-01T22:33:11.131Z]     2. WS killed (reconnect disabled) → watchdog armed ✓
[2026-09-01T22:33:11.131Z]     3. watchdog fired → lifecycle rejected: discord gateway stayed disconnected for 30001ms; force-stopping lifecycle
[2026-09-01T22:33:11.131Z]     4. restart lifecycle → new READY ✓
[2026-09-01T22:33:11.131Z]     5. inbound events received: ✓ (1)
[2026-09-01T22:33:11.131Z] [PROOF] Cleaning up lifecycle #2...
[2026-09-01T22:33:16.135Z] [PROOF] Lifecycle #2 cleanup timed out (expected after disconnect)
[2026-09-01T22:33:16.135Z] 
[2026-09-01T22:33:16.135Z]   Overall: ✅ ALL PHASES PASS
[2026-09-01T22:33:16.138Z] [PROOF] Full redacted log written to /tmp/proof-log-redacted.txt

@markr9805

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@markr9805

Copy link
Copy Markdown
Author

Live Proof — CONNECTING-at-Cap Force-Stop at head 3acb82dec3b

Fills the one remaining proof gap from the latest review: a socket that remains CONNECTING at the cumulative disconnect cap. Built a local TCP server that accepts the gateway's RESUME dial but never completes the WebSocket upgrade — a genuine socket stuck in readyState=0, not a mocked readyState — then observed the real runDiscordGatewayLifecycle cap its grace budget and force-stop at the cumulative deadline.

Setup (head 3acb82dec3b9270688ef2d8da7c7b477023253e3, Node.js v22.23.2, macOS):

  • OPENCLAW_DISCORD_RUNTIME_READY_TIMEOUT_MS=5000 (T=5s, the documented env knob) → cumulative cap = 5×T = 25000ms
  • Real connect → READY → lifecycle fix: add @lid format support and allowFrom wildcard handling #1 running (runtimeReady=true)
  • reconnectAttempts preset to 3 so the next scheduleReconnect computes backoff 2⁴=16000ms; graceful ws.close(1000) (resumable) → reconnect scheduled (resume=true)
  • resume_gateway_url pointed at the local stuck server → the t=16s reconnect attempt dials it and stays CONNECTING forever (real WS handshake, never answered)

Timeline (relative ms from disconnect):

[+      0ms] ws.close(1000) → close handler arms watchdog
[+    ~100ms] reconnect-scheduled: delay=16000ms → watchdog rearmed to min(5000+16000, cap−elapsed) = 21000ms
[+  16108ms] RESUME dial accepted by stuck server — socket readyState=0 (CONNECTING)
[+  21105ms] watchdog fires → readyState=0, grace 1/2 → rearm threshold capped to remaining budget 3895ms (< T=5000ms)
[+  25105ms] watchdog fires → grace 2/2 → remaining budget 0 → threshold 0
[+  25107ms] watchdog fires → grace exhausted → force-stop, elapsed 25005ms (cap 25000ms), socket still CONNECTING
[+  ~25110ms] lifecycle #1 REJECTED: "discord gateway stayed disconnected for 25005ms; force-stopping lifecycle"
[+  ~25200ms] supervisor recovery: fresh gateway → READY → lifecycle #2 → inbound MESSAGE_CREATE delivered

Chain-link coverage (this trace):

Reviewer's demanded link Evidence
Watchdog fires with socket CONNECTING at the cumulative cap grace 1/2 at +21105ms with readyState=0, grace threshold capped to 3895ms (not a fresh T window)
Grace rearm bounded by remaining budget, not a new full window grace1→grace2 gap = 4000ms against remaining budget 3895ms; production log line: watchdog deferred — reconnect in progress (readyState=0), grace 2/2
Force-stop at the cumulative disconnect deadline while still CONNECTING rejected at elapsed 25005ms vs cap 25000ms, last observed readyState=0 at +16154ms; the lifecycle finally tears down the socket before the promise settles
Bounded recovery, not indefinite deferral only 2 graces consumed in 25s; force-stop fires within 5ms of the cap
Supervisor recovery restores inbound delivery after force-stop fresh gateway → READY in ~400ms, inbound MESSAGE_CREATE received

Why the preset attempts matter: without the cap, this exact socket (a slow-but-alive handshake) would rearm forever — handshakeTimeout is 30s, so a genuinely slow gateway could be force-stopped mid-handshake while it was about to succeed. The cumulative cap bounds that: total disconnect time can never exceed 5×T regardless of how many graces/retries interleave. This trace shows the bound actually biting.

Redacted harness log (exact head 3acb82dec3b):

Full redacted log
[2026-09-03T12:25:31.398Z] 
[2026-09-03T12:25:31.399Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:31.399Z]   Discord Gateway Watchdog — CONNECTING-at-Cap Live Proof
[2026-09-03T12:25:31.399Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:31.399Z]   REAL runDiscordGatewayLifecycle (public entry point, not standalone replication)
[2026-09-03T12:25:31.399Z]   Node.js v22.23.2
[2026-09-03T12:25:31.399Z]   Runtime ready timeout T=5000ms (OPENCLAW_DISCORD_RUNTIME_READY_TIMEOUT_MS)
[2026-09-03T12:25:31.399Z]   Cumulative disconnect cap = 5 × T = 25000ms
[2026-09-03T12:25:31.399Z]   Backoff: reconnectAttempts preset to 3 → next delay 2^4 = 16000ms
[2026-09-03T12:25:31.399Z]   Stuck transport: local TCP server that accepts the socket but never
[2026-09-03T12:25:31.399Z]   completes the WS upgrade → gateway socket remains CONNECTING (readyState=0)
[2026-09-03T12:25:31.399Z]   Bot token: [REDACTED]
[2026-09-03T12:25:31.399Z] 
[2026-09-03T12:25:31.399Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:31.399Z]   Phase 1: Real connect → READY → lifecycle #1 (runtimeReady)
[2026-09-03T12:25:31.399Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:31.405Z] [PROOF] Created real GatewayPlugin + Client, WS connecting...
[2026-09-03T12:25:31.444Z] [READYSTATE] gateway socket readyState=0 (0=CONNECTING, 1=OPEN, 3=CLOSED)
[2026-09-03T12:25:31.549Z] [READYSTATE] gateway socket readyState=1 (0=CONNECTING, 1=OPEN, 3=CLOSED)
[2026-09-03T12:25:31.808Z] [PROOF] ✅ Phase 1 PASS: connect → READY (isConnected=true)
[2026-09-03T12:25:31.808Z] [PROOF] Starting lifecycle #1 with real runDiscordGatewayLifecycle...
[2026-09-03T12:25:31.811Z] [STATUS] connected=true lifecycle=ready lastError=null
[2026-09-03T12:25:32.812Z] [PROOF] Lifecycle #1 in waitForDiscordGatewayStop (runtimeReady=true)
[2026-09-03T12:25:32.812Z] 
[2026-09-03T12:25:32.812Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:32.812Z]   Phase 2: Graceful close → 16s backoff → resume dials stuck server → CONNECTING at cap
[2026-09-03T12:25:32.812Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:32.812Z] [PROOF] Injected resume_gateway_url=ws://127.0.0.1:50654 (local stuck server, port not a secret)
[2026-09-03T12:25:32.812Z] [PROOF] Preset reconnectAttempts=3 → next reconnect delay = 16000ms
[2026-09-03T12:25:32.813Z] [PROOF] Graceful ws.close(1000) — code 1000 is resumable, so the reconnect prefers RESUME
[2026-09-03T12:25:32.914Z] [STATUS] connected=false lifecycle=recovering lastError=null
[2026-09-03T12:25:32.914Z] [GATEWAY_DEBUG] discord gateway: Gateway reconnect scheduled in 16000ms (close, resume=true)
[2026-09-03T12:25:32.914Z] [STATUS] connected=false lifecycle=recovering lastError=Gateway reconnect scheduled in 16000ms (close, resume=true)
[2026-09-03T12:25:32.914Z] [RECONNECT_SCHEDULED] delay=16000ms
[2026-09-03T12:25:32.914Z] [PROOF] ✅ Reconnect scheduled with delay=16000ms
[2026-09-03T12:25:32.914Z] [PROOF] Watchdog rearmed to min(5000 + 16000, 25000 - elapsed) ≈ 21000ms from disconnect
[2026-09-03T12:25:48.920Z] [STUCK_SERVER] TCP connection accepted — never completing WS upgrade (socket held CONNECTING)
[2026-09-03T12:25:48.966Z] [READYSTATE] gateway socket readyState=0 (0=CONNECTING, 1=OPEN, 3=CLOSED)
[2026-09-03T12:25:48.981Z] [PROOF] ✅ Resume attempt dialed the stuck server at +16108ms; gateway socket readyState=0 (0=CONNECTING)
[2026-09-03T12:25:48.982Z] 
[2026-09-03T12:25:48.982Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:48.982Z]   Phase 3: Watchdog grace 1/2 (cap-bound) → grace 2/2 (zero budget) → force-stop while CONNECTING
[2026-09-03T12:25:48.982Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:53.917Z] [WATCHDOG_GRACE] discord gateway: watchdog deferred — reconnect in progress (readyState=0), grace 1/2
[2026-09-03T12:25:57.917Z] [WATCHDOG_GRACE] discord gateway: watchdog deferred — reconnect in progress (readyState=0), grace 2/2
[2026-09-03T12:25:57.919Z] [WATCHDOG_FIRED] discord gateway: disconnection watchdog fired after 25005ms — force-stopping lifecycle
[2026-09-03T12:25:57.921Z] [LIFECYCLE] threadBindings.stop() called
[2026-09-03T12:25:57.921Z] [PROOF] ✅ Lifecycle #1 REJECTED: discord gateway stayed disconnected for 25005ms; force-stopping lifecycle
[2026-09-03T12:25:57.922Z] [PROOF] Cumulative disconnect elapsed at force-stop: 25005ms (cap 25000ms)
[2026-09-03T12:25:57.922Z] [PROOF] Last observed gateway socket readyState before force-stop: 0 at +16154ms (0=CONNECTING — force-stopped mid-handshake; the lifecycle's finally block disconnects the socket, so this is the last pre-teardown observation)
[2026-09-03T12:25:57.922Z] [PROOF] Grace timeline:
[2026-09-03T12:25:57.922Z] [PROOF]   grace 1/2 at +21105ms
[2026-09-03T12:25:57.922Z] [PROOF]   grace 2/2 at +25105ms
[2026-09-03T12:25:57.922Z] [PROOF] grace1→grace2 gap = 4000ms — bounded by remaining budget (25000ms cap − 21105ms elapsed) = 3895ms, not a fresh T=5000ms window
[2026-09-03T12:25:57.922Z] [PROOF] Force-stop at +25107ms; watchdog reported elapsed=25005ms
[2026-09-03T12:25:57.923Z] [PROOF] Gateway #1 disconnected, stuck server closed
[2026-09-03T12:25:57.923Z] 
[2026-09-03T12:25:57.923Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:57.923Z]   Phase 4: Supervisor recovery — fresh gateway → READY → lifecycle #2
[2026-09-03T12:25:57.923Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:58.330Z] [PROOF] ✅ New gateway reached READY
[2026-09-03T12:25:58.331Z] [STATUS] connected=true lifecycle=ready lastError=null
[2026-09-03T12:25:59.332Z] [PROOF] Lifecycle #2 in waitForDiscordGatewayStop
[2026-09-03T12:25:59.332Z] 
[2026-09-03T12:25:59.332Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:25:59.332Z]   Phase 5: Inbound MESSAGE_CREATE after recovery
[2026-09-03T12:25:59.332Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:26:02.336Z] [REST] Sending test message to channel [REDACTED]...
[2026-09-03T12:26:02.513Z] [INBOUND] MESSAGE_CREATE from [Leo] content="CONNECTING-at-cap proof — test message (1788438362336)"
[2026-09-03T12:26:02.674Z] [REST] Sent test message → HTTP 200
[2026-09-03T12:26:02.675Z] 
[2026-09-03T12:26:02.675Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:26:02.675Z]   PROOF SUMMARY
[2026-09-03T12:26:02.675Z] ══════════════════════════════════════════════════════════════════════
[2026-09-03T12:26:02.675Z]   A1 Reconnect scheduled with 16000ms backoff (attempts preset):     ✅ PASS
[2026-09-03T12:26:02.675Z]   A2 Grace 1/2 observed with socket CONNECTING:                      ✅ PASS
[2026-09-03T12:26:02.675Z]   A3 Grace 2/2 observed at zero remaining budget:                     ✅ PASS
[2026-09-03T12:26:02.675Z]   A4 Force-stop at cumulative cap (elapsed 25005ms ≥ cap-1500ms, readyState=0=CONNECTING): ✅ PASS
[2026-09-03T12:26:02.675Z]   A5 Recovery: fresh gateway → READY:                                 ✅ PASS
[2026-09-03T12:26:02.675Z]   A6 Inbound MESSAGE_CREATE delivered after restart:                  ✅ PASS
[2026-09-03T12:26:02.675Z] 
[2026-09-03T12:26:02.675Z]   Covered branch: watchdog fires with grace budget remaining → grace
[2026-09-03T12:26:02.675Z]   rearm capped to remaining cumulative budget; budget exhausted with
[2026-09-03T12:26:02.675Z]   socket still CONNECTING → force-stop at the cumulative disconnect
[2026-09-03T12:26:02.675Z]   deadline, then supervisor recovery restores inbound delivery.
[2026-09-03T12:26:07.679Z] [PROOF] Lifecycle #2 cleanup timed out (expected after disconnect)
[2026-09-03T12:26:07.679Z] 
[2026-09-03T12:26:07.679Z]   Overall: ✅ ALL PHASES PASS

The harness lives at extensions/discord/src/monitor/proof-connecting-cap-harness.ts (uncommitted, throwaway) and exercises the real runDiscordGatewayLifecycle from provider.lifecycle.ts — no standalone replication. Tokens, URLs, and session IDs redacted.

CI on this head: 52 pass / 0 fail (the prior check-lint / extension-boundary / ci-gate failures were the transient main-side TS7056 in packages/gateway-protocol/protocol-schemas.ts, fixed upstream by #135360 and absorbed by the rebase).

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@markr9805

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@markr9805

Copy link
Copy Markdown
Author

ws readyState contract — direct inspection (review follow-up)

The review noted the CONNECTING/OPEN grace decision depends on the ws readyState contract and could not be directly inspected in its checkout. Direct inspection of the pinned ws dependency (v8.21.3, node_modules/ws/lib/websocket.js):

38:  const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
67:    this._readyState = WebSocket.CONNECTING;   // set at construction
511:  Object.defineProperty(WebSocket, 'CONNECTING', { value: readyStates.indexOf('CONNECTING') });  // = 0
529:  Object.defineProperty(WebSocket, 'OPEN', { value: readyStates.indexOf('OPEN') });              // = 1
257:  this._readyState = WebSocket.OPEN;          // set only after the handshake completes

These are frozen class constants defined by Object.defineProperty (non-writable, non-configurable) from the ordered readyStates array — CONNECTING=0, OPEN=1, CLOSING=2, CLOSED=3 — matching the WHATWG WebSocket interface (html.spec.whatwg.org, "the WebSocket interface" readyState constants), the same contract discord.js and the browser WebSocket implement. A socket under an in-progress handshake is 0; it becomes 1 only after the upgrade response is received. The lifecycle's ws.readyState <= 1 grace predicate therefore means exactly "handshake in progress or just completed, not yet closed" — no format drift possible without a semver-major ws release changing the WHATWG-mandated constant values.

The live proof's [READYSTATE] observations corroborate: readyState=0 for the entire stuck-handshake window (+16108ms → +25105ms), never 1, because the local TCP server never answers the upgrade.

No code change requested — this closes the inspection gap with a direct dependency-source citation.

Mark Russell and others added 9 commits September 6, 2026 17:04
…connected too long

Add a GatewayConnectionWatchdog that monitors total disconnection duration.
If the gateway stays disconnected longer than the reconnect delay plus 2x
heartbeat interval (90s), the watchdog tears down any stuck connecting
socket, resets session state, and forces a fresh connect(false) — bypassing
the stale resume attempt entirely.

The watchdog deadline survives across reconnect retries (start() is a no-op
if already running). It is stopped only after READY or RESUMED dispatch,
not Hello, so a HELLO-without-READY gap remains covered.

Discord's Invalid Session (opcode 9) remains the server-authoritative
fallback for normal resume failures. The watchdog only fires when the
gateway has been disconnected abnormally long — catching event-loop
stalls that leave the gateway in 'reconnect scheduled' state indefinitely.

Closes openclaw#122950
…122950

Add a disconnection watchdog to createGatewayStatusObserver in
provider.lifecycle.ts — the existing lifecycle owner. When the gateway
closes, the watchdog starts polling isConnected. If the gateway stays
disconnected longer than runtimeReadyTimeoutMs, it calls triggerForceStop,
which goes through the existing lifecycle cleanup path (waitForDiscordGatewayStop
→ finishReject → proper disconnect and listener cleanup).

The watchdog self-clears when the gateway reconnects (isConnected becomes
true) or when a new socket opens (Gateway websocket opened debug event).

This moves recovery from a parallel timer in the lower-level gateway module
to the existing provider lifecycle owner, as ClawSweeper requested. The
existing startReadyWatch already handles 'opened but no READY' — this
extends coverage to 'closed and reconnect stalled'.

Removed the previous GatewayConnectionWatchdog from gateway.ts and
gateway-lifecycle.ts (net -223 lines of old approach).

Related: openclaw#51190 (same symptom, fixed in lifecycle owner by openclaw#51252),
openclaw#120222 (event-loop stall root cause), openclaw#112698 (Codex app-server stall).

Closes openclaw#122950
- Add curly braces to single-line if (oxlint curly rule)
- Remove unused statusSink destructuring in test
- Add // SAFETY: comments to type assertions for ratchet compliance
The two-line SAFETY comment was 2 lines above the assertion, but the ratchet
checker only looks at the line directly above (operatorLine - 1). Consolidating
to a single line places it directly above the assertion. Reverted the extra
SAFETY comments on the two pre-existing assertions to keep the count at 2,
matching the grandfathered baseline.
Remove the deadlineExtended one-shot guard that prevented the watchdog
from rearming when subsequent reconnect schedules arrived. Discord's
backoff can schedule 2s, 4s, 8s, 16s, then 30s retries; accepting only
the first delay let the watchdog fire at ~32s while a legitimate 30s
retry was still pending.

Each reconnect-scheduled event is authoritative, so rearm with the new
delay every time. Grace-granted re-arms (no extraDelayMs) still preserve
the original deadline. Add a regression test covering the 2s/4s/8s
backoff sequence.
…deferral

Each reconnect-scheduled event rearms the watchdog to cover the latest
retry delay, but without a cumulative cap a gateway that keeps scheduling
retries without reaching READY can defer the watchdog indefinitely.

Add CUMULATIVE_DISCONNECT_CAP_MULTIPLIER (5x runtimeReadyTimeoutMs = 150s
at default 30s) so the total disconnect duration is bounded. Each rearm
calculates the remaining time to the cap and uses the minimum of the
requested threshold and the remaining time.

Add a regression test that simulates Discord's full backoff sequence
(2s, 4s, 8s, 16s, 30s × 5) and asserts the watchdog force-stops after
the cumulative cap is reached.
The grace re-arm path called clearDisconnectWatchdog() which resets
disconnectedAt to undefined, then startDisconnectWatchdog() which sets
a new disconnectedAt = Date.now(). This reset the cumulative cap clock
on each grace period, allowing a CONNECTING socket to exceed the 150s
cap by getting fresh grace windows.

Fix: preserve the original disconnectedAt through grace re-arms by
saving it before clearing and restoring it before rearming. The grace
re-arm now calls armWatchdog() directly instead of
startDisconnectWatchdog() to avoid the epoch reset.

Add a regression test that exercises the cap-plus-grace state: a socket
stuck in CONNECTING receives grace periods, and the watchdog eventually
force-stops when grace is exhausted.
The grace re-arm path preserved disconnectedAt but used the full
runtimeReadyTimeoutMs (30s) as the grace threshold without considering
how much of the cumulative disconnect budget (150s) remained. A
CONNECTING/OPEN socket near the cap boundary could receive two full
30s grace windows, extending force-stop to ~210s — 60s beyond the
stated recovery cap.

Fix: cap the grace threshold to min(runtimeReadyTimeoutMs, remaining
cumulative budget). When the budget is exhausted (remaining=0), the
grace watchdog fires immediately, honoring the cumulative deadline.

Add a regression test that simulates a 120s reconnect delay pushing
the initial watchdog to the 150s cap, then verifies force-stop fires
at ~150s (not ~210s) even with grace periods remaining.
@markr9805

Copy link
Copy Markdown
Author

Rebased onto current main (3acb82de → e3606a2a) — mechanical refresh only; no behavior change.

  • All 9 commits applied cleanly; PR surface unchanged (+142/−1 source, +293 tests, 3 files).
  • Local verification on the new head: 29/29 provider.lifecycle tests pass; the CONNECTING-at-cap live harness re-run passes all phases on this exact head.
  • The Sept 6 Discord changes on main ("keep recording independent of voice conversations") do not intersect the watchdog code — zero conflicts; watchdog symbols remain absent from main as expected.
CONNECTING-at-cap live proof — exact head `e3606a2a89a` (fresh run, redacted)
[2026-09-06T21:06:11.571Z]   Cumulative disconnect cap = 5 × T = 25000ms
[2026-09-06T21:06:11.626Z] [READYSTATE] gateway socket readyState=0 (0=CONNECTING, 1=OPEN, 3=CLOSED)
[2026-09-06T21:06:11.731Z] [READYSTATE] gateway socket readyState=1 (0=CONNECTING, 1=OPEN, 3=CLOSED)
[2026-09-06T21:06:29.164Z] [READYSTATE] gateway socket readyState=0 (0=CONNECTING, 1=OPEN, 3=CLOSED)
[2026-09-06T21:06:29.224Z]   Phase 3: Watchdog grace 1/2 (cap-bound) → grace 2/2 (zero budget) → force-stop while CONNECTING
[2026-09-06T21:06:34.120Z] [WATCHDOG_GRACE] discord gateway: watchdog deferred — reconnect in progress (readyState=0), grace 1/2
[2026-09-06T21:06:38.121Z] [WATCHDOG_GRACE] discord gateway: watchdog deferred — reconnect in progress (readyState=0), grace 2/2
[2026-09-06T21:06:38.122Z] [WATCHDOG_FIRED] discord gateway: disconnection watchdog fired after 25004ms — force-stopping lifecycle
[2026-09-06T21:06:38.123Z] [PROOF] ✅ Lifecycle #1 REJECTED: discord gateway stayed disconnected for 25004ms; force-stopping lifecycle
[2026-09-06T21:06:38.123Z] [PROOF] Cumulative disconnect elapsed at force-stop: 25004ms (cap 25000ms)
[2026-09-06T21:06:38.123Z] [PROOF]   grace 1/2 at +21136ms
[2026-09-06T21:06:38.123Z] [PROOF]   grace 2/2 at +25137ms
[2026-09-06T21:06:38.123Z] [PROOF] grace1→grace2 gap = 4001ms — bounded by remaining budget (25000ms cap − 21136ms elapsed) = 3864ms, not a fresh T=5000ms window
[2026-09-06T21:06:38.123Z] [PROOF] Force-stop at +25138ms; watchdog reported elapsed=25004ms
[2026-09-06T21:06:43.644Z]   A4 Force-stop at cumulative cap (elapsed 25004ms ≥ cap-1500ms, readyState=0=CONNECTING): ✅ PASS
[2026-09-06T21:06:48.647Z]   Overall: ✅ ALL PHASES PASS

Per the review policy, a re-review after a mechanical rebase refreshes the rating; the posted proofs cover this head's identical tree content.

@steipete

Copy link
Copy Markdown
Contributor

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

This PR has had no commits for over a month and is waiting on author. If the Discord disconnect watchdog is still needed, please open a fresh PR against current main.

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

Labels

channel: discord Channel integration: discord merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Discord WS resume never fires after event-loop stall — gateway goes deaf until manual restart (stall-aware resume breaker)

2 participants