[pull] main from react:main#513
Merged
Merged
Conversation
…r) (#36873) A Node.js `Buffer` carries a `toJSON` method, so Flight serializes it through that method instead of as binary, and it is deserialized as a plain `{type: 'Buffer', data: [...]}` object rather than a `Buffer` or `Uint8Array`. The warning React emits in this case reads "Uint8Array objects are not supported", which is misleading on two counts: the value is actually a `Buffer`, reported as `Uint8Array` only because that is its `Object.prototype.toString` tag, and a real `Uint8Array` is in fact supported, since it has no `toJSON` and serializes as binary. This makes the message especially confusing when binary data such as a font is passed as a serialized value. The first commit adds a test that pins down the current behavior, capturing both the misleading warning and the deserialization to a plain `{type: 'Buffer', data: [...]}` object. The second commit replaces the warning, for values that are `ArrayBuffer.isView`, with one that names the actual cause and the fix: the data is serialized through `toJSON` instead of as binary, so a `Uint8Array` or `ArrayBuffer` should be passed to send binary data. The new branch only fires for a typed array that also carries a `toJSON`, which in practice is a Node `Buffer`; a plain `Uint8Array` or `ArrayBuffer` has no `toJSON`, never reaches this branch, and continues to serialize as binary.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )