Repository navigation
Conversation
POST /send returned 500 "provider transport failure" after 157ms: the Twitch request failed at the connection, before any response. Go's transport only replays such failures on reused connections, and never replays a POST otherwise, so a connection that failed during setup surfaced as an error although Twitch never saw the message. clients.Do now traces each request. When the transport began getting a connection and wrote nothing (no headers, no request), the request had no effect, so it is resent once whatever its method. A request that may have been written stays an error, so a chat message is never posted twice, and a transport that reports neither is treated as ambiguous. (Twitch keeps idle connections for 240s, longer than Go's 90s idle timeout, so a server-closed idle connection isn't the cause.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EzdqAWrbTMdtJutmK41coy
This branch has not been deployed
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
CJ3zuIS42bCqcg:clients.Doreturnsprovider transport failurewhen the HTTP client gets no response at all. Go's transport replays a failed request only on a reused connection, and never replays a POST otherwise. So a connection that fails during setup (dial, TLS handshake, reset before anything is sent) surfaces as an error, even though Twitch never saw the chat message.I checked whether the cause was idle connections: a live keep-alive connection to
api.twitch.tvstayed open 240s before closing. That's longer than Go's 90s idle timeout, so Twitch closing stale connections isn't it, and this PR doesn't tune timeouts.Fix
clients.Donow attaches anhttptrace.ClientTraceto each request and resends once, whatever the method, only on positive evidence that the request never left:GetConn) and wrote nothing (noWroteHeaders, noWroteRequest). That request had no effect.The trace flags are read only after
client.Doreturns. On error, Go's transport waits for its write loop to finish before returning (mapRoundTripErrorwaits onwriteLoopDone), so a late write is always visible. A write that fails partway can't deliver a complete request.Tests
TestDoResendsRequestsThatWereNeverWrittenruns a TLS server that drops the first connection during the handshake. Onmainthe POST fails withprovider transport failureand the server receives nothing. Here it succeeds, and the server receives the request exactly once.TestDoDoesNotResendWrittenRequestshas the server receive the POST and then drop the connection without answering. It fails as before, and the server still receives it only once.TestCleanupRetainsUncertaintyUntilDeleteIsSettled, whose fake transport models a lost DELETE response, caught my first draft (which treated "no trace hooks fired" as "unsent"). It now passes unchanged.go test -racepasses forclients,cmd,catalog,jobs,publichttp,subscriptions,webhook,providerandhandler.Generated by Claude Code