Repository navigation
fix(api): let media uploads outlive the server-wide timeouts - #13
Merged
Merged
Conversation
POST /media runs under the server's ReadTimeout (15 s), which in Go covers the whole request, body included, plus a 30 s WriteTimeout. Any upload slower than that is cut off: at 10 MB/s the real limit is about 150 MB, far below the documented 512 MiB, and clients see a connection error instead of a 413. Give this route a 15-minute window with http.ResponseController and keep the short timeouts everywhere else. responseRecorder needs Unwrap so the controller can reach the connection. Claude-Session: https://claude.ai/code/session_01G9tsQQuw2iiBtGxGTp23qH
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
POST /mediaruns under the server-wideReadTimeoutof 15 s (cmd/postflow-server/main.go). In Go that timeout covers the whole request, body included, so any upload slower than 15 s is cut off. At 10 MB/s the real limit is about 150 MB, far below the documented 512 MiB.Clients see a connection error, not a 413, so it looks like a network problem:
Seen with real videos: every file from 157 MB to 3 GB failed after 15-16 s, while files up to 130 MB got through at about 9 MB/s. The limit moves with upload speed, which is why the same file can pass one day and fail the next.
Fix
Give this route a 15-minute window with
http.ResponseControllerand keep the short timeouts for every other route.handleUploadMediaextends the read and write deadlines. The write deadline matters too:WriteTimeout(30 s) would otherwise stop the response to any upload that took longer.responseRecordergetsUnwrap(). Without it the controller can't reach the connection and the deadlines silently stay as they were.README.mdanddocs/specs/openapi.yamlstate the new limit.Testing
TestUploadMediaOutlivesServerTimeouts, which uploads through a real server with its timeouts scaled down.go test ./...has run against this branch. Please rely on CI here.Unwrap()it is still cut off; with both it completes in full.Out of scope
postflow_upload_media, base64 over/mcp) still run under the 15 s timeout.docs/specs/mvp.md.https://claude.ai/code/session_01G9tsQQuw2iiBtGxGTp23qH