fix: read the request body before closing a response (v2.3.1) - #18
Merged
Merged
Conversation
/health answered without ever reading the body the client sent, and Windows tears down a response closed over an unread request body with RST instead of FIN. The answer was written and the caller saw a dropped connection: 8 failures in 40 calls against a player, 2 in 40 against an editor, 0 in 40 once the body is drained first. The service logged nothing, because from its side the request had been served. Draining in the shared envelope writer covers the error responses too, where a reset would otherwise hide the status code that explains the failure. Every route that reads its own body was never affected, which is why only health showed it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
The defect
/healthbuilds its answer and writes it without ever reading the request bodythe client sent. Windows tears down a response closed over an unread request
body with RST instead of FIN, so the answer was written and the caller saw a
dropped connection —
WinError 10054— about one call in five.The service logged nothing, because from its side the request had been served.
Evidence
/healthwith a body (what the client sends)/healthwith an empty body/command— a route that reads its body — with a bodyOnly
healthwas affected, because it is the only route that never consumeswhat it was sent. Measured at 8/40 against a player and 2/40 against an editor.
Three other explanations were ruled out first: the failures return in 15ms so
they are not queueing behind the serial dispatch loop; request spacing from 0ms
to 300ms does not change the rate, so it is not a burst effect; and
runInBackgroundwas already on.The fix
Drain the body in
WriteEnvelopeResponseAsync, the writer every route shares.That covers the 404/415 error responses too, where a reset would otherwise hide
the status code that explains what went wrong.
Verified
0/40 and 0/60 against an editor, 0/40 twice against a rebuilt IL2CPP player,
and 40/40 through
cs healthwhere the same run previously lost calls.cs doctorandcs wait-readyprobe throughhealth, so both stop failing atrandom too.
🤖 Generated with Claude Code