Skip to content

fix(irc): monitor stays disconnected after IRC socket closes#100799

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-irc-monitor-reconnect
Jul 6, 2026
Merged

fix(irc): monitor stays disconnected after IRC socket closes#100799
vincentkoc merged 1 commit into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-irc-monitor-reconnect

Conversation

@zhangguiping-xydt

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

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where IRC channel users would stop receiving bot responses after the IRC server closed an already-established monitor connection. The monitor logged the socket error/close but did not establish a new IRC session, so inbound IRC messages were missed until the OpenClaw process was restarted.

Why This Change Was Made

The IRC client now reports unexpected post-ready socket closes to the monitor, and the monitor schedules a reconnect that reuses the same account config and channel join list. The client also closes sockets when IRC registration times out, so repeated reconnect attempts do not leave accepted-but-not-ready sockets behind. This does not change IRC config, auth, message parsing, or outbound send contracts.

User Impact

IRC channel monitors recover from transient network/server disconnects without requiring a manual OpenClaw restart. After reconnecting, the bot logs in again and rejoins its configured channels so inbound messages can be handled normally.

Evidence

Near-real IRC runtime proof uses the real monitorIrcProvider against a real loopback TCP IRC server. The server accepts a ready IRC session, observes JOIN #openclaw, closes that established socket, and then observes the monitor reconnect and rejoin the configured channel.

[server] accepted tcp connection #1
[server] #1 <= NICK bot
[server] #1 <= USER bot 0 * :OpenClaw Proof
[server] #1 => 001 welcome
[monitor info] [default] connected to 127.0.0.1:34279 as bot
[server] #1 <= JOIN #openclaw
[server] closing established connection #1 after JOIN #openclaw
[monitor warn] [default] IRC connection closed; reconnecting in 1000ms
[server] tcp connection #1 closed
[server] accepted tcp connection #2
[server] #2 <= NICK bot
[server] #2 <= USER bot 0 * :OpenClaw Proof
[server] #2 => 001 welcome
[monitor info] [default] connected to 127.0.0.1:34279 as bot
[server] #2 <= JOIN #openclaw
[proof] tcp_connections=2
[proof] user_registrations=2
[proof] channel_joins=2
[proof] PASS IRC monitor recovers after post-ready disconnect and rejoins configured channel

Focused regression checks:

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-irc.config.ts extensions/irc/src/monitor.test.ts

    Test Files  1 passed (1)
         Tests  4 passed (4)
    
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-irc.config.ts extensions/irc/src/client.test.ts -t "closes the socket when registration never becomes ready"

    Test Files  1 passed (1)
         Tests  1 passed | 15 skipped (16)
    

After syncing with current main, the previously failing unrelated CI areas were rechecked locally:

  • pnpm tsgo:prod

    $ pnpm tsgo:core && pnpm tsgo:extensions
    $ node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
    $ node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfo
    
  • pnpm lint --threads=2

    [oxlint:core] finished
    [oxlint:extensions] finished
    [oxlint:scripts] finished
    
  • node scripts/run-vitest.mjs run test/scripts/android-app-i18n.test.ts

    android-app-i18n: keys=26 locales=zh-CN,zh-TW,pt-BR,de,es,ja-JP,ko,fr,hi,ar,it,tr,uk,id,pl,th,vi,nl,fa,ru,sv
    Test Files  1 passed (1)
         Tests  2 passed (2)
    

@clawsweeper

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 7:46 AM ET / 11:46 UTC.

Summary
The PR changes the IRC plugin client and monitor to notify on post-ready socket closes, reconnect and rejoin configured channels, clean up timed-out registration sockets, and add loopback regression tests.

PR surface: Source +74, Tests +245. Total +319 across 4 files.

Reproducibility: yes. Source inspection shows current main has no post-ready close notification from the IRC client to the monitor, and the PR proof/test path exercises a ready close followed by reconnect and channel rejoin.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Get exact-head required CI green or rerun after the unrelated current failures are resolved on the base branch.

Risk before merge

  • [P1] Exact-head CI is not clean yet; the observed failures appear outside the IRC diff, but required checks still need a green run or maintainer-accepted rerun before merge.

Maintainer options:

  1. Decide the mitigation before merge
    Land the plugin-local IRC reconnect fix after required CI is clean because the proof now covers the requested real reconnect behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed because no blocking code finding remains; maintainer review should wait for clean required CI before merge.

Security
Cleared: The diff changes IRC socket lifecycle handling and tests only; it does not add dependencies, workflows, permissions, config, auth, or secret-handling surface.

Review details

Best possible solution:

Land the plugin-local IRC reconnect fix after required CI is clean because the proof now covers the requested real reconnect behavior.

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

Yes. Source inspection shows current main has no post-ready close notification from the IRC client to the monitor, and the PR proof/test path exercises a ready close followed by reconnect and channel rejoin.

Is this the best way to solve the issue?

Yes. The IRC client is the right layer to report transport disconnects, while the IRC monitor is the right layer to reconnect using account config and joined channels.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 90e1ef176820.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body includes redacted terminal-style live output from monitorIrcProvider against a loopback TCP IRC server showing socket close, reconnect, and rejoin.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The updated PR body includes redacted terminal-style live output from monitorIrcProvider against a loopback TCP IRC server showing socket close, reconnect, and rejoin.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The PR fixes a bounded IRC channel availability bug where inbound messages can be missed after a socket close until restart.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The updated PR body includes redacted terminal-style live output from monitorIrcProvider against a loopback TCP IRC server showing socket close, reconnect, and rejoin.
  • proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body includes redacted terminal-style live output from monitorIrcProvider against a loopback TCP IRC server showing socket close, reconnect, and rejoin.
Evidence reviewed

PR surface:

Source +74, Tests +245. Total +319 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 150 76 +74
Tests 2 247 2 +245
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 397 78 +319

What I checked:

  • Current main IRC client behavior: Current main only fails the ready promise when the socket closes before registration is ready; after a ready socket closes it sets closed without notifying the monitor, matching the stuck-disconnected path. (extensions/irc/src/client.ts:430, 90e1ef176820)
  • Current main IRC monitor behavior: Current main creates one IRC client and stop only quits that client; there is no reconnect scheduling around the established monitor connection. (extensions/irc/src/monitor.ts:63, 90e1ef176820)
  • PR reconnect implementation: The PR head adds monitor-local reconnect scheduling and wires the IRC client's disconnect callback to schedule a reconnect unless the monitor has stopped or aborted. (extensions/irc/src/monitor.ts:78, 8232574fb2a5)
  • PR client lifecycle implementation: The PR head adds the onDisconnect callback after ready socket close and closes timed-out registration sockets before rethrowing the timeout error. (extensions/irc/src/client.ts:431, 8232574fb2a5)
  • Focused regression coverage: The PR adds a monitor test that accepts a ready IRC session, closes it, and waits for a second login, plus a client test that verifies timed-out registration sockets are closed. (extensions/irc/src/monitor.test.ts:116, 8232574fb2a5)
  • Caller and owner boundary: The IRC gateway starts monitorIrcProvider through runStoppablePassiveMonitor, whose shared helper only starts and stops passive monitors; it does not observe IRC transport socket close events. (src/plugin-sdk/extension-shared.ts:83, 90e1ef176820)

Likely related people:

  • vignesh07: First-class IRC channel support introduced the IRC client and monitor files that contain the current single-session monitor behavior. (role: introduced behavior; confidence: medium; commits: fa906b26add7; files: extensions/irc/src/client.ts, extensions/irc/src/monitor.ts)
  • steipete: GitHub history shows repeated IRC plugin and monitor-runtime maintenance, including shared monitor runtime setup and IRC helper refactors touching the relevant monitor boundary. (role: recent area contributor; confidence: medium; commits: 1ac4bac8b1ab, 0183610db372, dc1d6856bcc1; files: extensions/irc/src/monitor.ts, extensions/irc/src/client.ts, src/plugin-sdk/extension-shared.ts)
  • yetval: Recent merged IRC client work touched the same client file and loopback test style, though the prior change was about PRIVMSG chunking rather than monitor reconnects. (role: recent adjacent contributor; confidence: low; commits: 89881b6611a1; files: extensions/irc/src/client.ts, extensions/irc/src/client.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-06T10:26:29.117Z sha 8232574 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 6, 2026
@zhangguiping-xydt
zhangguiping-xydt force-pushed the fix/problem-irc-monitor-reconnect branch from 8232574 to 117e2f3 Compare July 6, 2026 12:35
@vincentkoc
vincentkoc force-pushed the fix/problem-irc-monitor-reconnect branch from 117e2f3 to b14404c Compare July 6, 2026 12:47
@vincentkoc
vincentkoc force-pushed the fix/problem-irc-monitor-reconnect branch from b14404c to a3e376f Compare July 6, 2026 12:53
@vincentkoc vincentkoc self-assigned this Jul 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member

maintainer validation complete; this is ready to land.

  • final PR head: a3e376f85b60de6ed67ac5eeb2731098820348f8
  • changed surface: exactly four IRC client/monitor source and test files
  • focused patch-identical Testbox tbx_01kwvqfqwn03v2drmhf259qw56: corepack pnpm test:serial extensions/irc/src/client.test.ts extensions/irc/src/monitor.test.ts passed 20/20
  • same Testbox: OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed passed
  • exact-head hosted CI run 28792948478 passed, including QA Smoke
  • fresh final-head Codex autoreview: clean, no accepted/actionable findings, confidence 0.82
  • native review artifacts validated with zero findings
  • native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 100799 passed using hosted exact-head evidence

behavior proof covers an established IRC connection being closed by the server, followed by reconnect, registration, and rejoin. explicit stop/abort cancels pending reconnects, registration timeout destroys the incomplete socket, and initial connection failure remains fail-closed.

known proof gaps: none for this bounded channel lifecycle change.

@vincentkoc
vincentkoc merged commit 5aa7c62 into openclaw:main Jul 6, 2026
91 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

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

Labels

channel: irc P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants