Skip to content

fix(twitch): wait for authentication before probe success - #178354

Merged
steipete merged 1 commit into
mainfrom
deslop/z41-11-plugin-boundaries-20261015
Oct 20, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/z41-11-plugin-boundaries-20261015

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Twitch status probes report a successful connection before Twitch accepts the OAuth credentials. A working IRC socket is not an authenticated chat session.

Why This Change Was Made

Twurple emits onConnect for the underlying IRC transport, then emits onAuthenticationSuccess when IRC registration completes. Wait for the latter in the probe, matching the normal Twitch client. Authentication failure, disconnect, the existing timeout, and client cleanup remain unchanged.

User Impact

Rejected credentials produce a failed probe instead of a misleading successful status. No configuration, SDK, protocol, dependency, or persistence change. Phase E memory machinery is untouched.

Best-effort tradeoffs accepted

None. This repairs a normal authentication-status outcome and removes no guard.

Evidence

  • Regression on the original probe: transport connect followed by authentication failure returned ok: true; exactly one new case failed and four existing cases passed (24.01s wrapper, 12.47s Vitest wall).
  • Candidate: 54 tests / 5 files passed, covering the probe, registered plugin, client/registry lifecycle, and lint suppressions. Wrapper wall 364.47s; messaging shard 307.26s, dominated by cold compilation. The probe regression's test body completed in milliseconds; hosted CI seconds are pending. No timeout, retry, skip, or assertion weakening.
  • Focused syntax lint, formatting, and whitespace checks passed. Scoped graph: 28 production files, zero runtime cycles and zero new static components versus pinned base d8c96213c5cf.
  • Targeted package types could not qualify locally because generated public SDK declarations are absent (TS2307 and downstream inference errors). No broad build, stubs, or suppressions were added. Exact-head hosted CI 39413554395 passed, including production/test types, extension lint, selected tests, and the aggregate gate. No live Twitch account or channel proof is claimed.
  • Independent P0–P2 review completed scoped-clean, including final source verification.

Production LOC: net zero (+2/-2); this is a bug fix, not a LARGE cleanup. Release-note context: Twitch status waits for accepted credentials before reporting success.

@clawsweeper

clawsweeper Bot commented Oct 20, 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.

@steipete
steipete marked this pull request as ready for review October 20, 2026 11:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T11:17:48.247683Z aff5597 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added channel: twitch Channel integration: twitch size: XS labels Oct 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

const authFailListener = probeClient.onAuthenticationFailure(() => {
cleanup();
reject(new Error("Authentication failed"));

P1 Badge Cancel Twurple's queued retry before rejecting authentication

When Twitch emits the authentication failure handled here, the pinned @twurple/chat 8.2.0 client emits this callback and then waits its Fibonacci backoff before calling _ircClient.reconnect(). Rejecting causes the probe's finally to call quit(), but that does not cancel Twurple's already-scheduled continuation; it subsequently reconnects after all three probe listeners have been unbound and can continue retrying in the background. Because gateway health/status may invoke this probe repeatedly, rejected credentials can accumulate orphaned Twitch clients and sockets; cancel or otherwise own the library retry through settlement before returning the failed probe.

AGENTS.md reference: extensions/AGENTS.md:L23-L25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR makes Twitch probes wait for successful IRC authentication before reporting success.

Example: The testbot account connects, then Twitch sends Login authentication failed.

  • Before: The probe reports ok: true on transport connection.
  • After: The probe reports ok: false with Authentication failed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The status correction is useful and focused, but the retry lifecycle defect blocks correctness and supplied proof uses mocked transport events.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Twitch status can show a successful connection even though Twitch has not accepted the credentials.
Reason: Authentication is the meaningful success boundary for this credential probe, and the maintainer-authored direction is approved.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: it fixes a real false-success status, but waiting for authentication exposes a retry lifecycle defect that can leave probe clients reconnecting after cleanup.

Priority: P2
Reviewed head: aff55978da50c73ef8a010b4ef5e32720c94ba4f

Before merge

  • Stop authentication retries before releasing the probe client (P2) - Waiting past transport connection now allows an IRC authentication rejection to reach Twurple's retry handler. In pinned @twurple/chat 8.2.0, a Login authentication failed notice emits onAuthenticationFailure, awaits a backoff, and unconditionally calls _ircClient.reconnect(). The probe rejects, removes its listeners, and calls quit() in finally, but quit() does not cancel that continuation; ircv3 reconnect() explicitly starts another connection. Repeated failed status probes can therefore leave orphaned clients reconnecting after their results have returned. Ensure the one-shot probe cannot reconnect after settlement and cover this with the real transport client rather than a mock quit call count.

Findings

  • [P2] Stop authentication retries before releasing the probe client — extensions/twitch/src/probe.ts:53-56

Tests

  • Missing end-to-end proof: Supply real-client probe evidence for accepted and rejected IRC authentication, including no reconnect or socket activity after settlement.
Agent review details

How this fits together

The Twitch plugin's status adapter passes account credentials and a timeout to probeTwitch, which creates a temporary Twurple chat client and returns connection status.

flowchart LR
  A[Channel status request] --> B[Twitch status adapter]
  B --> C[Temporary probe client]
  C --> D[Twitch IRC authentication]
  D --> E[Probe result]
  C --> F[Client cleanup]
Loading

Technical review

Best possible solution:

Keep authentication-based success and make the temporary probe's transport lifecycle end completely when the probe settles.

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

Source confirms that current main accepts transport connection before authentication; the PR reports a matching failing baseline test, but this review executed no target code.

Is this the best way to solve the issue?

Changing the success event is the smallest status correction, but the real dependency's authentication retry must also remain owned through teardown.

Full review comments:

  • [P2] Stop authentication retries before releasing the probe client — extensions/twitch/src/probe.ts:53-56
    Waiting past transport connection now allows an IRC authentication rejection to reach Twurple's retry handler. In pinned @twurple/chat 8.2.0, a Login authentication failed notice emits onAuthenticationFailure, awaits a backoff, and unconditionally calls _ircClient.reconnect(). The probe rejects, removes its listeners, and calls quit() in finally, but quit() does not cancel that continuation; ircv3 reconnect() explicitly starts another connection. Repeated failed status probes can therefore leave orphaned clients reconnecting after their results have returned. Ensure the one-shot probe cannot reconnect after settlement and cover this with the real transport client rather than a mock quit call count.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Twitch probe success boundary changes intended behavior with a stated reason (f5c90f0: The original implementation described verifying the OAuth connection but resolved on onConnect; refactor(channels): deslop channels #165718 later simplified listener bindings without intending behavior changes.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

  • Introduced change: The pinned introduction changes success from onConnect to onAuthenticationSuccess and adds one regression for authentication rejection after transport connection. (extensions/twitch/src/probe.ts:53, aff55978da50)
  • Current main still has the defect: Current main resolves the probe on transport connection; the registered Twitch status adapter calls this probe directly. (extensions/twitch/src/probe.ts:53, a52ba4f23384)
  • Dependency contract applies: The probe imports ChatClient from @twurple/chat, and the Twitch package pins version 8.2.0; its event ordering and teardown behavior determine this PR's correctness. (extensions/twitch/package.json:13, aff55978da50)
  • Authentication retry survives quit: Version 8.2.0 emits onAuthenticationFailure, awaits its backoff, and calls _ircClient.reconnect unconditionally; quit only destroys rate limiters and calls quitAbruptly. This independently supports the concern recorded at fix(twitch): wait for authentication before probe success #178354 (review). (packages/chat/src/ChatClient.ts:1157, cc80718e10a6)
  • Reconnect starts another connection: The lockfile resolves ircv3 0.33.1; its reconnect method calls quit followed by connect, while quitAbruptly only disconnects the current connection. (src/IrcClient.ts:463, 5752956dc2b5)
  • Supplied validation and discussion: The full body reports a red-on-base regression and 54 passing candidate tests, explicitly disclaims live Twitch proof, and supplies no real-client authentication capture; all discussion comments and the existing review were read. (aff55978da50)

Likely related people:

  • Peter Steinberger: Raw commit 846bef9 adds extensions/twitch/src/probe.ts:32 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 846bef946dbc; files: extensions/twitch/src/probe.ts)
  • jaydenfyi: Raw commit f5c90f0 adds extensions/twitch/src/probe.ts:24 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f5c90f0e5c7a; files: extensions/twitch/src/probe.ts)
  • Vincent Koc: Raw commit cc23d2a adds extensions/twitch/src/probe.test.ts:157 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: cc23d2a7f8b4; files: extensions/twitch/src/probe.test.ts)

PR surface

Source 0, Tests +25. Total +25 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 2 0
Tests 1 26 1 +25
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 28 3 +25

Labels

Label changes:

  • add P2: Incorrect Twitch health status and leaked retrying probe clients affect a limited channel surface without evidence of a core outage.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Incorrect Twitch health status and leaked retrying probe clients affect a limited channel surface without evidence of a core outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 20, 2026, 7:30 AM ET / 11:30 UTC.

@steipete
steipete merged commit 2d40bdf into main Oct 20, 2026
195 of 196 checks passed
@steipete
steipete deleted the deslop/z41-11-plugin-boundaries-20261015 branch October 20, 2026 11:40
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

channel: twitch Channel integration: twitch P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS 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.

1 participant