mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-07 15:57:53 +08:00
The snapshot taken before dispatching the OAuth response handler still used raw c.Writer.Size(), while handleOpenAIImagesOAuthResponseError compares it against the keepalive-adjusted size. From the second failover round on, the previous round's heartbeat bytes made the raw snapshot positive while the adjusted size stayed -1, so a retryable upstream error was misjudged as 'response already written': the failover was swallowed and the client got a committed 200 with a whitespace-only body. Snapshot now uses OpenAIImagesJSONKeepaliveAdjustedWrittenSize, matching the comparison side. Regression test simulates a prior-round heartbeat before ForwardImages and asserts the retryable error still converts to UpstreamFailoverError (verified red without the fix, green with it).