Repository navigation
[Flight Reply] Decode FormData part ids as hex - #37879
Open
zhoubiao188 wants to merge 1 commit into
Open
zhoubiao188 wants to merge 1 commit into
zhoubiao188 wants to merge 1 commit into
Conversation
`$K<id>` encodes the part id in hex like every other reference, but `parseModelString` passed the raw substring straight through as the prefix for the backing entries. The client writes those entries as `<formFieldPrefix>_<refId>_<key>`, where `refId` is the decimal number, so the two representations only agree for ids below 10. For any part id of 10 or higher the prefix doesn't match, the cursor never advances past the block, and the referenced FormData deserializes as an empty FormData -- silently dropping every field. That's reachable from `encodeReply` whenever ten or more parts are outlined before the FormData (promises, blobs, typed arrays, other FormData, ...), and from bound Server Actions whose bound arguments include one. Decode the id the same way the Blob, typed array and stream branches in this file already do.
|
Comparing: 098d2e8...66d9f2b Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) Generated by sizebot against 66d9f2b |
This branch has not been deployed
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.
Summary
A
FormDatapassed to a Server Action is deserialized as an emptyFormDatawhenever its part id is 10 or higher, silently dropping every field.The wire format is
$K<id>withidin hex, like every other reference in the protocol. But the backing entries are written by the client under<formFieldPrefix>_<refId>_<key>, whererefIdis interpolated as a decimal number:parseModelStringthen used the raw hex substring as the key prefix instead of converting it back:The two representations only agree below 10, so for any id >= 10 the lookup matches nothing.
consumeBackingEntriesreturns an emptyFormDataand, because it doesn't advance the cursor, the entries are left behind for the rest of the reply.Every other id-carrying branch in the same function already decodes hex before building a backing key —
parseTypedArray(parseInt(reference.slice(2), 16)),'B'(parseInt(value.slice(2), 16)),getOutlinedModel(parseInt(path[0], 16)) andgetChunk(takes anumber).'K'was the only exception.This is reachable from
encodeReplywhenever ten or more parts are outlined before theFormData(promises,Blobs, typed arrays, iterators, otherFormDatas...), and from bound Server Actions whose bound arguments include one.Test
Added a case to
ReactFlightDOMReply-test.jsthat outlines nine promises first, so theFormDatabecomes part 10 — the first id whose hex form differs from its decimal form. Failing output before the fix:Verification
ReactFlightDOMReply(webpack / Node / Edge),ReactFlightDOMForm,ReactFlightTurbopackDOMReply,ReactFlightDOMNode— all pass onexperimental, plus-r=stableand--prodfor the reply suites.yarn lincandprettier check-changedclean.parseTypedArrayfurther down the same file and adds its tests earlier in the samedescribeblock.