Skip to content

Stop joining Twitch channels that don't exist - #1757

Merged
kevmo314 merged 2 commits into
mainfrom
claude/eager-dijkstra-hdrup8
Nov 4, 2026
Merged

kevmo314 merged 2 commits into
mainfrom
claude/eager-dijkstra-hdrup8

Conversation

@kevmo314

@kevmo314 kevmo314 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Problem

Error group CLvRh7feg8O2eg, preceded by three CJWX4_7f9Obpcg warnings for channel wwh1k:

08:28:17 WARN  failed to join channel as anonymous: context deadline exceeded
08:28:28 WARN  failed to join channel as authed user: context deadline exceeded
08:28:38 WARN  failed to join channel as realtimechat: context deadline exceeded
08:28:38 ERROR failed to open request: failed to join channel

twitch.tv/wwh1k doesn't exist. I checked live against irc-ws.chat.twitch.tv how Twitch IRC answers a JOIN for a missing channel: it sends nothing. There is no NOTICE and no ROOMSTATE, while #twitch on the same connection got its ROOMSTATE right away. So the agent made three anonymous attempts, then joined as the broadcaster, then as realtimechat. Each one timed out against the same silence, and the request ended as an error report.

Fix

IRC gives no signal for a missing channel, so the agent asks Helix instead:

  • JoinAnonymously: after the first join times out, it calls GET /users?login= with the app access token, which it already uses elsewhere. If there's no such user, it returns the new ErrChannelUnavailable at once. Joins that succeed never make the lookup. A connection failure (as opposed to a timeout) doesn't trigger it either. If the lookup itself fails, the previous retries continue unchanged, so a Helix outage can't make things worse.
  • newClientWithFallbacks: on ErrChannelUnavailable it skips the broadcaster and realtimechat fallbacks, which would be met with the same silence.
  • requestManager: logs twitch channel unavailable at info level instead of failed to open request at error level. A channel Twitch doesn't have is bad assignment data, not an agent failure.

For a missing channel this takes the join from five timeouts (about 50s, five IRC connections and an alert) down to one timeout plus one Helix call. The request is still retried whenever its assignment changes, at that lower cost.

Tests

  • TestAnonymousJoinOfMissingChannel (under synctest) uses a fake chat that never sends ROOMSTATE, matching the live behavior. A missing channel stops after 1 join with ErrChannelUnavailable. An existing channel and a failed lookup both keep all 3 attempts.
  • TestAnonymousJoinDoesNotLookUpOnConnectionFailure checks that connection errors don't trigger a lookup.
  • TestMissingChannelStopsFallbacks checks that neither the profile lookup nor the user joins run.
  • TestMissingChannelIsNotAnAgentError checks that no client is kept and nothing is logged at error level.

go test -race ./internal/handler ./cmd passes. go test ./... passes except internal/youtube's live tests (TestLiveMetadata, TestLiveMetadataSession), which hit youtube.com and are untouched by this diff.


Generated by Claude Code

An assignment for twitch:wwh1k, a login with no Twitch account, raised
"failed to open request: failed to join channel". Twitch IRC never
answers a JOIN for a missing channel (verified live: no NOTICE and no
ROOMSTATE), so the agent spent three anonymous joins and both fallback
identities waiting out timeouts before reporting an error.

After the first anonymous join times out, the agent now asks Helix
whether the login exists. If it doesn't, the join returns
ErrChannelUnavailable at once, the fallbacks are skipped, and the
request manager logs it at info level. Joins that succeed make no
lookup, and a failed lookup keeps the previous retry behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EzdqAWrbTMdtJutmK41coy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EzdqAWrbTMdtJutmK41coy
@kevmo314
kevmo314 merged commit fddd9f3 into main Nov 4, 2026
8 checks passed
@kevmo314
kevmo314 deleted the claude/eager-dijkstra-hdrup8 branch November 4, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants