Repository navigation
Conversation
🦋 Changeset detectedLatest commit: fdda428 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance2 warnings
Comparing Footnotes
|
|
Thanks for tracking this down. Both bugs are real: a GET call with the codec on turns a file into Could you narrow the fix, though? Choosing GET or POST should stay the developer's call, so a GET with a file shouldn't quietly switch to POST. Could you instead:
That should cost far fewer than 118 B, and may not need the cap raises at all. Generated by Claude Code |
… to POST Narrowed per review. A GET server function whose codec arguments encode to multipart form data (a file among them) now throws "A GET server function cannot send files: use POST" before sending, instead of putting `[object FormData]` in the url. Without the codec, a GET call with a file still throws the existing enableRichArguments error. The long-argument POST fallback keeps the encoding it already made: GET passes it as the options body and the codec branch of initializeResponse sends it, so a one-shot argument such as an async iterator arrives with all its chunks. Size: +106 B minified on every server-function page. Caps raised at measured + 10 B over main @ 5420b4a for compiled base, compiled live and live + router, and for the frozen live page floor, which needs a Size-Exception line in the PR body.
Summary
A
GETserver function called with a file in its arguments sends the codec's multipart body as a url parameter, and the server answers 400:The same happens for
(1, file), aFormDataholding a file, and an object holding aBlob. The default POST transport delivers all of them. The docs say that with the codec on "files and blobs can sit anywhere in the arguments ... Such a call sends multipart form data", and that GET "arguments too long for a url dispatch over POST instead". GET'ssendinpackages/web/server-functions/src/client.tsputserializeArguments(args)straight into?args=. Since #4208 that can be aFormData. Same on 2.0.3 and main.The url-length fallback had a related problem: it encoded the arguments a second time. So a long codec argument next to a one-shot async iterator arrived with no chunks.
GET's
sendnow sends the codec's output over POST, still as a read, when it can't go in the url (aFormData, or a codec string that is too long). It uses the same request shape as the default POST transport's codec branch, now a smallwithCodecBodyhelper both paths call, so the arguments are encoded once. JSON-safe calls and short codec strings such as aDatestill go over GET with the same url and cache key. POST-shaped reads still never ask for single-flight.Behavior change
Without
enableRichArguments, a GET call whose argument has a natural HTTP encoding (aFile,Blob,FormData,URLSearchParams,ArrayBufferor typed array, alone or as the last bound argument) now goes over POST as a read, the same way the default POST transport sends it. Before, it threw "pass a single Blob/FormData/File argument". Nested values,Date,Map,undefined,(Date, File)and(File, 1)still throw theenableRichArgumentsmessage without sending a request.Without the codec, a long leading argument before a file stays in
?args=on that POST, exactly as the default POST transport sends the same call.Public API changes
None.
Size
+118 B minified on each server-function page bundle (measured locally on macOS). Two non-floor scenarios go past their allowance, so this PR raises their caps at measured + 10 B with ledger lines in
scripts/size/scenarios.js: compiled base server components 36.06 → 36.15 KB, live + router 51.47 → 51.51 KB. The frozen base server components floor stays under its cap by 5 B brotli. If CI measures more than that, it needs aSize-Exception:line. #5175 raises some of the same caps, so whichever lands second needs its ledger lines re-measured.How did you test this change?
packages/web/test/server/server-functions-uploads.spec.tsx:(1, File)and aFormDataholding a file go over POST as reads.On main the file cases fail with
Server function call failed with status 400. The iterator and long-argument cases also fail on a version that re-encodes (chunks: [],?args=…).packages/web/test/server/server-functions-body-formats.spec.tsx: without the codec, a File goes over POST (on main it throws the "pass a single Blob/FormData/File" error), and a nestedDatestill asks for the codec.Probed 26 argument shapes with the codec on and off, plus
invoke(GET(fn), { signal })and calls inside an action. GET urls for JSON-safe and codec-string arguments are unchanged, and no GET-declared call sendsX-Single-Flight.Web server suite 2228 passed, web client suite 2033 passed,
test-typespasses.