Skip to content

Support null-prototype objects in Flight#36818

Open
yaacovCR wants to merge 5 commits into
react:mainfrom
yaacovCR:null-prototype
Open

Support null-prototype objects in Flight#36818
yaacovCR wants to merge 5 commits into
react:mainfrom
yaacovCR:null-prototype

Conversation

@yaacovCR

@yaacovCR yaacovCR commented Jun 18, 2026

Copy link
Copy Markdown

Summary

Flight currently rejects objects with a null prototype. That prevents passing map-like records that are intentionally protected from prototype pollution, even though their enumerable string keys are otherwise serializable data.

This is useful for data stores such as graphql-js response stores where keys are not necessarily controlled. The change serializes null-prototype objects with a dedicated Flight marker and revives them with Object.create(null), while preserving keys such as proto as own data properties.

How did you test this change?

  • yarn prettier
  • yarn linc
  • yarn flow dom-node-webpack
  • yarn test ReactFlight-test ReactFlightDOMReply-test
  • yarn test --prod ReactFlight-test ReactFlightDOMReply-test --testNamePattern="null-prototype"

Beyond the React unit tests, yaacovCR/graphql-incremental-delivery-client-examples#2 demonstrates the fix in a real react-server-dom-webpack Server-to-Client serialization path: its fixture calls renderToReadableStream with GraphQL.js's raw null-prototype summary object, asserts that React reports no serialization errors, and checks that the emitted Flight payload includes the null-prototype marker.

## Motivation

Flight currently rejects objects with a null prototype. That prevents passing map-like records that are intentionally protected from prototype pollution, even though their enumerable string keys are otherwise serializable data.

This is useful for data stores such as graphql-js response stores where keys are not necessarily controlled. The change serializes null-prototype objects with a dedicated Flight marker and revives them with Object.create(null), while preserving keys such as __proto__ as own data properties.

The downstream GraphQL incremental delivery example now has the problem and fix split across two PRs. yaacovCR/graphql-incremental-delivery-client-examples#1 captured the failing RSC boundary after passing the raw GraphQL.js execution result through a Client Component prop. yaacovCR/graphql-incremental-delivery-client-examples#2 applies this React change as a local react-server-dom-webpack patch and flips that boundary test to prove the raw null-prototype product.summary object serializes successfully.

## How did you test this change?

- yarn prettier
- yarn linc
- yarn flow dom-node-webpack
- yarn test ReactFlight-test ReactFlightDOMReply-test
- yarn test --prod ReactFlight-test ReactFlightDOMReply-test --testNamePattern="null-prototype"

I also ran yarn test --prod ReactFlight-test ReactFlightDOMReply-test. The new null-prototype tests passed, but the full production run still failed in existing ReactFlight production error stack expectations unrelated to this change.

Beyond the React unit tests, yaacovCR/graphql-incremental-delivery-client-examples#2 demonstrates the fix in a real react-server-dom-webpack Server-to-Client serialization path: its fixture calls renderToReadableStream with GraphQL.js's raw null-prototype summary object, asserts that React reports no serialization errors, and checks that the emitted Flight payload includes the null-prototype marker. That example PR was verified with npm run verify.
@meta-cla

meta-cla Bot commented Jun 18, 2026

Copy link
Copy Markdown

Hi @yaacovCR!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Jun 18, 2026

@daltino daltino left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR introduces support for null-prototype objects in React Flight by adding serialization and deserialization methods, as well as enhancing tests to ensure this functionality works correctly. The changes are well-contained and align with the goal of improving compatibility with different object types.

@yaacovCR

yaacovCR commented Jul 2, 2026

Copy link
Copy Markdown
Author

Just a gentle ping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants