Repository navigation
Phone uploads: a too-large file gets its 413, not a dropped connection - #33
Merged
Merged
Conversation
The server refused an oversized upload without reading its body. Java's HTTP server sends nothing until the body is read, and closing on unread bytes resets the connection, so the client could lose the answer and see only a dropped connection. That is what made PhoneServerTest.anUploadNeedsTheSecretAndFitsTheLimit flaky on CI. - The server now reads and drops the rest of a refused body (up to twice the limit) before answering 413. - The phone page checks the file size before sending and says the file is too large, so a browser never sends one; a test keeps its limit equal to the server's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes the flaky
PhoneServerTest.anUploadNeedsTheSecretAndFitsTheLimit. It failed onmainon Nov 21 and on #32's first macOS run.Cause
The server refused an oversized upload on its
Content-Lengthwithout reading the body. Java's built-in HTTP server sends no response until the request body has been read. When it closes a connection with bytes still unread, the OS resets the connection. Depending on timing, the reset can arrive before the 413 does, and the client then seesheader parser received no bytes. A phone uploading a file over 25 MB could hit the same race and get a vague network error instead of the "too large" message.Changes
Content-Lengthcheck and to the counted (chunked) path.app.jschecks the file size before sending and says the file is too large, so a browser never sends one. A new test keepsMAX_UPLOAD_BYTESinapp.jsequal toPhoneUploads.MAX_BYTES.Testing
mvn -pl app -am test: 640 tests pass.PhoneServerTest: 15/15 runs pass.header parser received no bytesin 2 out of 2 runs against the old server, and passed 2 out of 2 runs (80 uploads, all answered 413) with this change.🤖 Generated with Claude Code