Repository navigation
Stop joining Twitch channels that don't exist - #1757
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Error group
CLvRh7feg8O2eg, preceded by threeCJWX4_7f9Obpcgwarnings for channelwwh1k:twitch.tv/wwh1kdoesn't exist. I checked live againstirc-ws.chat.twitch.tvhow Twitch IRC answers a JOIN for a missing channel: it sends nothing. There is no NOTICE and no ROOMSTATE, while#twitchon the same connection got its ROOMSTATE right away. So the agent made three anonymous attempts, then joined as the broadcaster, then asrealtimechat. 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 callsGET /users?login=with the app access token, which it already uses elsewhere. If there's no such user, it returns the newErrChannelUnavailableat 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: onErrChannelUnavailableit skips the broadcaster andrealtimechatfallbacks, which would be met with the same silence.requestManager: logstwitch channel unavailableat info level instead offailed to open requestat 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(undersynctest) uses a fake chat that never sends ROOMSTATE, matching the live behavior. A missing channel stops after 1 join withErrChannelUnavailable. An existing channel and a failed lookup both keep all 3 attempts.TestAnonymousJoinDoesNotLookUpOnConnectionFailurechecks that connection errors don't trigger a lookup.TestMissingChannelStopsFallbackschecks that neither the profile lookup nor the user joins run.TestMissingChannelIsNotAnAgentErrorchecks that no client is kept and nothing is logged at error level.go test -race ./internal/handler ./cmdpasses.go test ./...passes exceptinternal/youtube's live tests (TestLiveMetadata,TestLiveMetadataSession), which hit youtube.com and are untouched by this diff.Generated by Claude Code