Repository navigation
chore: merge upstream facebook/react main - #1
Merged
Merged
Conversation
keeps off for RN oss until the next branch cut
…rite test (react#38326) "interrupts the stream when a write fails" renders a model whose `first` promise is already resolved, so the root row and the faulty typed array go out in the same flush. Whether the root reaches the client then depends on how the rows before it split into writes. React writes a string row longer than a third of its view directly, after flushing the buffer. On Node 20, the partial-view copy warning adds a console replay row and its stack row. When the stack row crosses that size, the root lands in a later write that the stream queues, and erroring the stream discards it. `createFromReadableStream` then rejects instead of only `first`. The stack row's length depends on the checkout path and the stack depth, so the test passed or failed based on where the repo lives and how many frames sit above the write. It fails in long local worktree paths, and in CI when a change adds one frame to the task loop. The test now resolves `first` after the client has read the root, so the faulty chunk is always written in a later flush. Co-authored-by: Claude <noreply@anthropic.com>
[Ledgers] Write Ledger entries to the response stream Implements `addToLedger` and writes Ledger entries to the response stream. The decoding side is not yet implemented; will be added in a subsequent PR. The rendering model for Ledgers reuses existing concepts and machinery as closely as possible. Ledgers are streamed incrementally like all other data in Flight. The server does not buffer ledger values beyond the current render phase, except that until the first capture is serialized it keeps each unit's pending deltas, since earlier work may still be reused by a capture rendered later. Materializing an accumulated ledger value is handled on the client, rather than maintaining a running balance on the server. This is a core part of the design: Ledgers never block the rendering of the main data response, nor do they affect Flight's ability to cache them. Similar to preload hints, a Ledger entry is written to the stream using a separate set of response rows from the main data. The client can decode these rows without having to decode the corresponding data. This is important because it preserves the laziness of the client's processing work. Likewise, the work needed to materialize a Ledger on the client (i.e. traversing the graph and reducing the entries to an accumulated total) is lazily performed only if something awaits the result. In general, a key design principle is to avoid new bookkeeping or complexity on the server by deferring the computation to the client. Additional work during the decode is relatively cheap, especially since it's lazy. Whereas any additional complexity on the server risks compromising streaming or caching performance. The main part of the design that's novel to Ledgers is that we must track which "unit" of work spawned a Ledger entry. A unit is any reusable bit of rendering computation, i.e. a Flight task or a `React.cache` entry. This is required to enable caching and deduping of Ledger entries. Unit tracking is the one part of the design that requires overhead that is not proportional to Ledger usage, because the units must be tracked even before we know any entries have been written. For example, we must be able to dedupe a cached object before it has fully finished rendering, and therefore before knowing whether it will write Ledger entries later in the stream. However, the overhead is measured to be relatively minimal, and while it's not proportional to Ledger usage, it is proportional to caching and deduping. I used synthetic benchmarks to measure the impact while iterating on the implementation. On a realistically shaped page (about 1,000 components, 170 KB of payload, 500 React.cache hits), unit tracking adds on the order of 20 µs to about a millisecond of Flight serialization, roughly 2%, and under 0.1% of a request that waits on data. Theoretically, in the future we could use Units for replaying other kinds of render effects, like prefetch hints. Currently there's no reason to do this for hints because hints are intentionally hoisted to the top of the response. - `K`: Declares a Ledger type's identity. The body includes Ledger's kind (Bit, Set, etc). - `Y`: Represents a `captureLedgers` instance. The body refers to the Ledger type declaration (its K row). - `Q`: Declares a Unit, written lazily the first time a Ledger entry is rendered inside it. - `Z`: Data entries added to a Ledger. One per Unit per Ledger per flush. (Notice this is not the same as once per `addToLedger` call. If multiple `addToLedger` calls to the same Ledger happen in the same flush window, they will get batched into a single `Z` row.) - `F`: Represents a reused reference. One per Unit per flush. This combined with the `Q` rows are what enables Ledgers to be cached and reused across different parts of the tree.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 21, 2026
chore: merge upstream facebook/react main DiffTrain build for [db4b90d](react@db4b90d)
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 21, 2026
chore: merge upstream facebook/react main DiffTrain build for [db4b90d](react@db4b90d)
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
The fork's
mainis 3 commits behindfacebook/reactmain. This PR merges them into the fork with a merge commit.Upstream commits included:
043ce5953c[Ledgers] Write Ledger entries to the response stream ([Ledgers] Write Ledger entries to the response stream react/react#37590)e1a76b4910[Flight] Write the faulty chunk in its own flush in the interrupted-write test ([Flight] Write the faulty chunk in its own flush in the interrupted-write test react/react#38326)7b22099e3c[flags] try removing legacy mode in rn-fb again ([flags] try removing legacy mode in rn-fb again react/react#37736)The merge had no conflicts. The fork's own commits (the
swc_fork_react_compiler*crate rename and the release docs) are unchanged.How did you test this change?
Local validation was not performed. CI on this PR is the check for the merge.