dillon1000/react

Commit

[Fizz] Guard the shell-error callbacks instead of nulling them out on the request (#36916)

Follow-up to #36903

The previous change stopped `onAllReady` from firing after a fatal shell
error by assigning `noop` to `request.onAllReady` inside `fatalError`.
This mutated a completion callback on the request as a side channel,
mirroring the existing `request.onShellError = noop` in `completeShell`.
This refactor removes both noop assignments and instead guards the calls
at the point where they would happen, so the callbacks on the request
stay the ones the caller passed in.

For `onAllReady`, `erroredTask` now returns right after `fatalError` in
the root (`boundary === null`) case, so it no longer falls through to
the `allPendingTasks === 0` check that calls `completeAll`. This matches
the sibling `finishAbortedTask`, which already returns after a fatal
root error. Later task completions cannot reach `completeAll` either,
because `performWork` bails out once the request status is past `OPEN`.

For `onShellError`, `fatalError` now decides whether to call it based on
the same condition that governed the assignment: the shell is complete
exactly when `request.pendingRootTasks === 0`, and `completeShell` only
runs at that point, so guarding the call is equivalent to the previous
nulling out. `onFatalError` still always fires because the error is
always fatal to the request.

This is a behavior-preserving refactor of the fix landed in #36903; the
tests added there continue to pass unchanged.

Co-authored-by: Claude Opus 4.7 <[email protected]>
Browse files
Changed paths1 file
First-parent comparison
M packages/react-server/src/ReactFizzServer.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…