Skip to content

[Fizz] Finish abort in a scheduled task#36580

Open
gnoff wants to merge 2 commits into
facebook:mainfrom
gnoff:jstory/delayed-abort
Open

[Fizz] Finish abort in a scheduled task#36580
gnoff wants to merge 2 commits into
facebook:mainfrom
gnoff:jstory/delayed-abort

Conversation

@gnoff
Copy link
Copy Markdown
Collaborator

@gnoff gnoff commented May 30, 2026

abort() currently aborts the request synchronously. This change delays the final abort to be in a scheduled task if the renderer supports this. At the moment this doesn't semantically change anything however it sets the stage to allow abort reason specialization by allowing pending tasks to reject with a more specific reason in between the abort start and it's completion.

the change is observable in some cases however because if you are reading from the stream you might end up serializing what previously was a client rendered boundary as a pending boundary that is then is marked client rendered in a later instruction.

This also fixes a subtle error reporting issue where if the sync abort during rendering puts the request into fatal status the abort reason for the currently rendering task is not reported through onError because the request is already CLOSED or CLOSING. now by delaying the abort finish the currently rendering task always gets a chance to finish while the request is ABORTING status.

@meta-cla meta-cla Bot added the CLA Signed label May 30, 2026
@github-actions github-actions Bot added the React Core Team Opened by a member of the React Core Team label May 30, 2026
@react-sizebot
Copy link
Copy Markdown

react-sizebot commented May 30, 2026

Comparing: f39ed9f...1ffc433

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.11% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 614.26 kB 614.26 kB = 108.57 kB 108.57 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 680.19 kB 680.19 kB = 119.51 kB 119.51 kB
facebook-www/ReactDOM-prod.classic.js = 700.61 kB 700.61 kB = 123.09 kB 123.09 kB
facebook-www/ReactDOM-prod.modern.js = 690.93 kB 690.93 kB = 121.48 kB 121.48 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactDOMServerStreaming-dev.modern.js +1.60% 419.75 kB 426.48 kB +1.76% 75.21 kB 76.54 kB
oss-stable-semver/react-server/cjs/react-server.development.js +0.67% 211.60 kB 213.02 kB +0.40% 37.35 kB 37.50 kB
oss-stable/react-server/cjs/react-server.development.js +0.67% 211.60 kB 213.02 kB +0.40% 37.35 kB 37.50 kB
oss-experimental/react-server/cjs/react-server.development.js +0.65% 216.39 kB 217.81 kB +0.41% 38.27 kB 38.43 kB
oss-stable-semver/react-server/cjs/react-server.production.js +0.58% 146.89 kB 147.74 kB +0.53% 25.82 kB 25.96 kB
oss-stable/react-server/cjs/react-server.production.js +0.58% 146.89 kB 147.74 kB +0.53% 25.82 kB 25.96 kB
oss-experimental/react-server/cjs/react-server.production.js +0.56% 150.37 kB 151.22 kB +0.48% 26.61 kB 26.73 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.development.js +0.31% 389.78 kB 390.97 kB +0.20% 73.93 kB 74.08 kB
oss-stable/react-dom/cjs/react-dom-server.bun.development.js +0.31% 389.85 kB 391.05 kB +0.20% 73.96 kB 74.10 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js +0.30% 404.00 kB 405.20 kB +0.16% 76.26 kB 76.39 kB
oss-experimental/react-markup/cjs/react-markup.development.js +0.29% 397.56 kB 398.73 kB +0.17% 72.16 kB 72.28 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.development.js +0.29% 410.51 kB 411.68 kB +0.16% 74.30 kB 74.42 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.29% 410.51 kB 411.69 kB +0.17% 74.30 kB 74.42 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.development.js +0.29% 410.54 kB 411.71 kB +0.17% 74.33 kB 74.45 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.29% 410.54 kB 411.71 kB +0.17% 74.33 kB 74.45 kB
facebook-www/ReactDOMServer-dev.modern.js +0.28% 421.05 kB 422.23 kB +0.18% 75.61 kB 75.74 kB
facebook-www/ReactDOMServer-dev.classic.js +0.28% 424.49 kB 425.66 kB +0.18% 76.22 kB 76.36 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js +0.28% 425.83 kB 427.00 kB +0.18% 76.53 kB 76.67 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.28% 425.83 kB 427.00 kB +0.18% 76.53 kB 76.67 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.development.js +0.27% 440.03 kB 441.23 kB +0.20% 78.47 kB 78.63 kB
oss-stable/react-dom/cjs/react-dom-server.browser.development.js +0.27% 440.11 kB 441.31 kB +0.21% 78.52 kB 78.68 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.development.js +0.27% 440.81 kB 442.01 kB +0.19% 78.66 kB 78.81 kB
oss-stable/react-dom/cjs/react-dom-server.edge.development.js +0.27% 440.89 kB 442.09 kB +0.20% 78.71 kB 78.86 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.development.js +0.27% 447.07 kB 448.27 kB +0.20% 78.46 kB 78.62 kB
oss-stable/react-dom/cjs/react-dom-server.node.development.js +0.27% 447.15 kB 448.35 kB +0.20% 78.51 kB 78.67 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js +0.26% 456.39 kB 457.59 kB +0.20% 80.79 kB 80.95 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.development.js +0.26% 457.40 kB 458.60 kB +0.20% 81.03 kB 81.19 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js +0.26% 463.16 kB 464.35 kB +0.20% 80.80 kB 80.96 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.24% 250.95 kB 251.55 kB +0.23% 45.22 kB 45.32 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.24% 250.97 kB 251.58 kB +0.23% 45.24 kB 45.34 kB
facebook-www/ReactDOMServer-prod.modern.js +0.23% 257.52 kB 258.13 kB +0.22% 46.01 kB 46.11 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.production.js +0.23% 278.58 kB 279.23 kB +0.25% 49.56 kB 49.69 kB
oss-experimental/react-markup/cjs/react-markup.production.js +0.23% 248.07 kB 248.65 kB +0.19% 46.00 kB 46.09 kB
oss-stable/react-dom/cjs/react-dom-server.browser.production.js +0.23% 278.66 kB 279.31 kB +0.25% 49.59 kB 49.71 kB
facebook-www/ReactDOMServer-prod.classic.js +0.23% 259.86 kB 260.46 kB +0.23% 46.36 kB 46.46 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.23% 260.74 kB 261.34 kB +0.23% 46.64 kB 46.75 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.production.js +0.23% 256.15 kB 256.73 kB +0.18% 47.20 kB 47.28 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.production.js +0.23% 256.18 kB 256.76 kB +0.18% 47.22 kB 47.31 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.production.js +0.22% 279.62 kB 280.25 kB +0.21% 49.33 kB 49.43 kB
oss-stable/react-dom/cjs/react-dom-server.bun.production.js +0.22% 279.70 kB 280.33 kB +0.21% 49.35 kB 49.45 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.js +0.22% 290.00 kB 290.64 kB +0.23% 51.19 kB 51.31 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.production.js +0.22% 284.49 kB 285.12 kB +0.22% 51.78 kB 51.89 kB
oss-stable/react-dom/cjs/react-dom-server.edge.production.js +0.22% 284.56 kB 285.19 kB +0.22% 51.80 kB 51.91 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.js +0.22% 266.52 kB 267.09 kB +0.18% 48.86 kB 48.95 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.js +0.22% 290.88 kB 291.51 kB +0.20% 51.11 kB 51.21 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.js +0.21% 292.55 kB 293.18 kB +0.21% 51.62 kB 51.73 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.js +0.21% 292.63 kB 293.25 kB +0.21% 51.65 kB 51.76 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.production.js +0.21% 296.58 kB 297.20 kB +0.21% 53.65 kB 53.77 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.js +0.21% 304.30 kB 304.93 kB +0.19% 53.50 kB 53.61 kB

Generated by 🚫 dangerJS against 1ffc433

gnoff added 2 commits May 30, 2026 11:41
There are parts of Fizz that need to schedule work regardless of whether the primary rendering pathway is drive externally through performWork. Historically scheduleWork and later s
cheduleMicrotask were noops in this bundle but it makes it hard to reason about the code because you cannot be assured that calling scheduleWork will actually result in the function
 ever executing. Now we model this explicitly through config. For builds that drive work through external calls to performaWork we simply omit any work scheduling in startWork or pi
ngTask. Now that this is modeled explicitly we can implement scheduleMicrotask and scheduleWork to actually provide a guarantee that the callbacks will get invoked.

For now I've implemented these two for the fb build as synchronous however it is likely that queueMicrotask and setTimeout or similar are preferred.
`abort()` currently aborts the request synchronously. This change delays the final abort to be in a scheduled task if the renderer supports this. At the moment this doesn't sematnically change anything however it sets the stage to allow abort reason specialization by allowing pending tasks to reject with a more specific reason in between the abort start and it's completion.

the change is observable in some cases however because if you are reading from the stream you might end up serializing what previously was a client rendered boudnary as a pending boundary that is then is marked client rendered in a later instruction.

This also fixes a subtle error reporting issue where if the sync abort during rendering puts the request into fatal status the abort reason for the currently rendering task is not reported through onError because the request is already CLOSED or CLOSING. now by delaying the abort finish the currently rendering task always gets a chance to finish while the request is ABORTING status.
@gnoff gnoff force-pushed the jstory/delayed-abort branch from 36fb8bc to 1ffc433 Compare May 30, 2026 18:49
@gnoff gnoff requested review from eps1lon and unstubbable and removed request for unstubbable May 30, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants