Skip to content

fix(discord): prevent stale gateway error listeners after restart#101617

Merged
steipete merged 3 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-discord-gateway-error-listener
Jul 9, 2026
Merged

fix(discord): prevent stale gateway error listeners after restart#101617
steipete merged 3 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-discord-gateway-error-listener

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Restarting or cleaning up the Discord gateway supervisor removed the disposed listener from a shared EventEmitter but could leave two bad outcomes: retaining old supervisor/runtime closures across restart cycles, or removing the last error listener so a delayed gateway error crashed the process.

Why This Change Was Made

The supervisor now owns one emitter-scoped late-error guard. Disposal removes the active supervisor listener and installs the guard only when no other error listener exists. A replacement supervisor removes the guard before attaching its active listener, so listener count stays bounded and no disposed runtime closure is retained.

The guard logs each distinct late error through the Discord gateway subsystem logger instead of silently swallowing it. Repeated identical late errors are deduplicated until the next supervisor starts.

User Impact

Discord channel restart and startup-cleanup paths no longer accumulate stale gateway listeners or crash on delayed emitter errors. Operators retain a bounded diagnostic when a late gateway error occurs.

Evidence

  • Blacksmith Testbox coral-crab (tbx_01kx2dacsrr1z0hjxenejbt9s5): 72 focused Discord tests passed across gateway supervisor, provider, gateway monitor, and provider lifecycle suites.
  • Blacksmith Testbox changed-surface gate passed: extension test typecheck, changed-file lint, database-first guard, media helper guard, runtime sidecar guard, and runtime import-cycle check.
  • Two fresh autoreview passes after the refactor and rebase: no actionable findings.
  • git diff --check passed.

The refactor preserves contributor authorship. Release-note context remains in this PR body for the release-owned changelog flow.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: XS labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head a53657a88a9129e4161dbda1c1e5c32691ebff11, but the PR head is now 9603dbc01a411b9684b35c90ab6cbf06cd2d6037. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (3 earlier review cycles)
  • reviewed 2026-07-07T12:04:56.506Z sha dc856cf :: needs real behavior proof before merge. :: [P1] Preserve a late-error guard after disposal
  • reviewed 2026-07-07T13:26:09.086Z sha bc17881 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-07T16:29:32.079Z sha 297f545 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 7, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels Jul 7, 2026
@steipete steipete self-assigned this Jul 9, 2026
@steipete
steipete force-pushed the fix/problem-discord-gateway-error-listener branch from 297f545 to 38a5333 Compare July 9, 2026 03:14
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Maintainer refactor and land-ready proof are complete on a53657a88a9129e4161dbda1c1e5c32691ebff11.

What changed:

  • rebased onto current main and removed the stale-supervisor retention path;
  • kept one emitter-owned late-error guard only while no active supervisor error listener exists;
  • routed distinct late errors through the Discord gateway subsystem logger and bounded duplicate diagnostics;
  • expanded lifecycle regression coverage; release-note context remains in the PR body for the release-owned changelog flow.

Proof:

  • Blacksmith Testbox coral-crab / tbx_01kx2dacsrr1z0hjxenejbt9s5:
    • pnpm test extensions/discord/src/monitor/gateway-supervisor.test.ts extensions/discord/src/monitor/provider.test.ts extensions/discord/src/monitor.gateway.test.ts extensions/discord/src/monitor/provider.lifecycle.test.ts — 72 passed;
    • pnpm check:changed — passed extension test typecheck, changed-file lint, database-first guard, media helper guard, runtime sidecar guard, and runtime import-cycle check.
  • git diff --check — passed.
  • Fresh autoreview after refactor and again after rebase — no actionable findings.

The behavior is exercised through the production supervisor with a real EventEmitter; no external Discord connection was needed for this teardown invariant.

@steipete
steipete force-pushed the fix/problem-discord-gateway-error-listener branch from a53657a to 9603dbc Compare July 9, 2026 03:17
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 9, 2026
@steipete
steipete merged commit 1017ea5 into openclaw:main Jul 9, 2026
102 of 110 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 9, 2026
…enclaw#101617)

* fix(discord): remove gateway error listener on dispose

* fix(discord): preserve late gateway error guard

* fix(discord): retain late gateway diagnostics

---------

Co-authored-by: Peter Steinberger <[email protected]>
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Jul 15, 2026
…enclaw#101617)

* fix(discord): remove gateway error listener on dispose

* fix(discord): preserve late gateway error guard

* fix(discord): retain late gateway diagnostics

---------

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit 1017ea5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord P1 High-priority user-facing bug, regression, or broken workflow. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants