Repository navigation
[Fizz] Postpone a task aborted while rendering from where it started - #37710
Conversation
|
Hi @AdzerKI! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn 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 If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Comparing: d083ec1...4c360a2 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) Generated by sizebot against 4c360a2 |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Can you restructure the PR into one commit characterizing the bug (assertions encode the faulty behavior i.e. the test passes) and a 2nd commit with the actual fix that updates the assertions to the desired behavior? Don't use |
bd91c39 to
ba95030
Compare
|
Done: the first commit adds the test asserting the current output ( |
eps1lon
left a comment
There was a problem hiding this comment.
Once the test style issue above is addressed, this is good to merge. Nice find, thank you!
Characterizes the current behavior: the prerender is aborted from a component rendered by a retried task, and the resume renders only the innermost child into the Suspense boundary.
ba95030 to
4c360a2
Compare
…37710) ## Summary Fixes #37709 When a prerender is aborted while a retried render task is on the stack, `retryRenderTask` resets the segment to where the attempt started, but `task.keyPath` and `task.childIndex` are left at the innermost child that was rendering. `abortUnwoundTask` then postpones the task at that child's slot under its parent element, and the resume renders only that child into the boundary's segment. This restores the key path and child index the attempt started from before finishing the abort, so the postponed hole covers the whole discarded attempt. `task.node` stays as is, since DEV async debug info reads it for the owner stack. ## How did you test this change? The first commit adds a test to `ReactDOMFizzStaticBrowser-test` that aborts the prerender from a component rendered by a retried task and resumes it, asserting the current output (`<div>World</div>`). The second commit is the fix and updates the assertion to the whole `<section>`. `yarn test packages/react-dom/src/__tests__/ReactDOMFizz packages/react-server` passes with and without `-r=experimental`. With `--prod`, `ReactServer › has Owner Stacks in DEV when aborted` fails the same way on main. Prettier, ESLint and `yarn flow dom-node` are clean. DiffTrain build for [07dde64](07dde64)
…eact#37710) ## Summary Fixes react#37709 When a prerender is aborted while a retried render task is on the stack, `retryRenderTask` resets the segment to where the attempt started, but `task.keyPath` and `task.childIndex` are left at the innermost child that was rendering. `abortUnwoundTask` then postpones the task at that child's slot under its parent element, and the resume renders only that child into the boundary's segment. This restores the key path and child index the attempt started from before finishing the abort, so the postponed hole covers the whole discarded attempt. `task.node` stays as is, since DEV async debug info reads it for the owner stack. ## How did you test this change? The first commit adds a test to `ReactDOMFizzStaticBrowser-test` that aborts the prerender from a component rendered by a retried task and resumes it, asserting the current output (`<div>World</div>`). The second commit is the fix and updates the assertion to the whole `<section>`. `yarn test packages/react-dom/src/__tests__/ReactDOMFizz packages/react-server` passes with and without `-r=experimental`. With `--prod`, `ReactServer › has Owner Stacks in DEV when aborted` fails the same way on main. Prettier, ESLint and `yarn flow dom-node` are clean. DiffTrain build for [07dde64](react@07dde64)
…eact#37710) ## Summary Fixes react#37709 When a prerender is aborted while a retried render task is on the stack, `retryRenderTask` resets the segment to where the attempt started, but `task.keyPath` and `task.childIndex` are left at the innermost child that was rendering. `abortUnwoundTask` then postpones the task at that child's slot under its parent element, and the resume renders only that child into the boundary's segment. This restores the key path and child index the attempt started from before finishing the abort, so the postponed hole covers the whole discarded attempt. `task.node` stays as is, since DEV async debug info reads it for the owner stack. ## How did you test this change? The first commit adds a test to `ReactDOMFizzStaticBrowser-test` that aborts the prerender from a component rendered by a retried task and resumes it, asserting the current output (`<div>World</div>`). The second commit is the fix and updates the assertion to the whole `<section>`. `yarn test packages/react-dom/src/__tests__/ReactDOMFizz packages/react-server` passes with and without `-r=experimental`. With `--prod`, `ReactServer › has Owner Stacks in DEV when aborted` fails the same way on main. Prettier, ESLint and `yarn flow dom-node` are clean. DiffTrain build for [07dde64](react@07dde64)
…eact#37710) ## Summary Fixes react#37709 When a prerender is aborted while a retried render task is on the stack, `retryRenderTask` resets the segment to where the attempt started, but `task.keyPath` and `task.childIndex` are left at the innermost child that was rendering. `abortUnwoundTask` then postpones the task at that child's slot under its parent element, and the resume renders only that child into the boundary's segment. This restores the key path and child index the attempt started from before finishing the abort, so the postponed hole covers the whole discarded attempt. `task.node` stays as is, since DEV async debug info reads it for the owner stack. ## How did you test this change? The first commit adds a test to `ReactDOMFizzStaticBrowser-test` that aborts the prerender from a component rendered by a retried task and resumes it, asserting the current output (`<div>World</div>`). The second commit is the fix and updates the assertion to the whole `<section>`. `yarn test packages/react-dom/src/__tests__/ReactDOMFizz packages/react-server` passes with and without `-r=experimental`. With `--prod`, `ReactServer › has Owner Stacks in DEV when aborted` fails the same way on main. Prettier, ESLint and `yarn flow dom-node` are clean. DiffTrain build for [07dde64](react@07dde64)
…eact#37710) ## Summary Fixes react#37709 When a prerender is aborted while a retried render task is on the stack, `retryRenderTask` resets the segment to where the attempt started, but `task.keyPath` and `task.childIndex` are left at the innermost child that was rendering. `abortUnwoundTask` then postpones the task at that child's slot under its parent element, and the resume renders only that child into the boundary's segment. This restores the key path and child index the attempt started from before finishing the abort, so the postponed hole covers the whole discarded attempt. `task.node` stays as is, since DEV async debug info reads it for the owner stack. ## How did you test this change? The first commit adds a test to `ReactDOMFizzStaticBrowser-test` that aborts the prerender from a component rendered by a retried task and resumes it, asserting the current output (`<div>World</div>`). The second commit is the fix and updates the assertion to the whole `<section>`. `yarn test packages/react-dom/src/__tests__/ReactDOMFizz packages/react-server` passes with and without `-r=experimental`. With `--prod`, `ReactServer › has Owner Stacks in DEV when aborted` fails the same way on main. Prettier, ESLint and `yarn flow dom-node` are clean. DiffTrain build for [07dde64](react@07dde64)
[diff react/react@b618bbb4...07dde64d](react/react@b618bbb...07dde64) <details> <summary>React upstream changes</summary> - react/react#37710 - react/react#37814 - react/react#37778 - react/react#37688 - react/react#37796 </details> --------- Co-authored-by: next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com> Co-authored-by: Sebastian Sebbie Silbermann <[email protected]>
## Summary A prerender can abort during a retry after the retried task has spawned a suspended child. Abort cleanup records a replay slot for the whole task, then tries to record a child slot at the same key path. Resuming the parent already renders that child, so the existing assertion turns a resumable abort into a prerender error. This surfaced after the abort unwind change in #37710. Keep the parent slot and ignore the redundant child slot. The regression test verifies that both children render after resuming. ## How did you test this change? - `yarn test ReactDOMFizzStaticBrowser --runInBand` (36 passed) - `yarn test ReactDOMFizzStaticBrowser --prod --runInBand` (36 passed) - `yarn linc` - `node scripts/prettier/index.js check-changed`
## Summary A prerender can abort during a retry after the retried task has spawned a suspended child. Abort cleanup records a replay slot for the whole task, then tries to record a child slot at the same key path. Resuming the parent already renders that child, so the existing assertion turns a resumable abort into a prerender error. This surfaced after the abort unwind change in #37710. Keep the parent slot and ignore the redundant child slot. The regression test verifies that both children render after resuming. ## How did you test this change? - `yarn test ReactDOMFizzStaticBrowser --runInBand` (36 passed) - `yarn test ReactDOMFizzStaticBrowser --prod --runInBand` (36 passed) - `yarn linc` - `node scripts/prettier/index.js check-changed` DiffTrain build for [e25b4a4](e25b4a4)
## Summary A prerender can abort during a retry after the retried task has spawned a suspended child. Abort cleanup records a replay slot for the whole task, then tries to record a child slot at the same key path. Resuming the parent already renders that child, so the existing assertion turns a resumable abort into a prerender error. This surfaced after the abort unwind change in #37710. Keep the parent slot and ignore the redundant child slot. The regression test verifies that both children render after resuming. ## How did you test this change? - `yarn test ReactDOMFizzStaticBrowser --runInBand` (36 passed) - `yarn test ReactDOMFizzStaticBrowser --prod --runInBand` (36 passed) - `yarn linc` - `node scripts/prettier/index.js check-changed` DiffTrain build for [e25b4a4](e25b4a4)
Revert #37710 and #37850 while we revisit how synchronous prerender aborts preserve replay state. Restoring the aborted task root as a replay point can overlap postpones from child tasks. #37850 suppresses one form of the overlap, but an indexed parent slot can still coexist with a descendant replay node and fail during resumption. This removes the incomplete change so we can address the replay invariants together. This deliberately restores the behavior reported in #37709: if a prerender abort interrupts a task after it has rendered part of its shell, the later resume can omit that markup. That regression needs a follow-up fix. This supersedes #37851. Tests: `yarn test ReactDOMFizzStaticBrowser --runInBand` and `yarn test ReactDOMFizzStaticBrowser --prod --runInBand` (34 passed in each mode).
Revert #37710 and #37850 while we revisit how synchronous prerender aborts preserve replay state. Restoring the aborted task root as a replay point can overlap postpones from child tasks. #37850 suppresses one form of the overlap, but an indexed parent slot can still coexist with a descendant replay node and fail during resumption. This removes the incomplete change so we can address the replay invariants together. This deliberately restores the behavior reported in #37709: if a prerender abort interrupts a task after it has rendered part of its shell, the later resume can omit that markup. That regression needs a follow-up fix. This supersedes #37851. Tests: `yarn test ReactDOMFizzStaticBrowser --runInBand` and `yarn test ReactDOMFizzStaticBrowser --prod --runInBand` (34 passed in each mode). DiffTrain build for [99c106c](99c106c)
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the completed shell by postponing the interrupted child and unvisited siblings without running more rendering code. This addresses react#37709 without restoring overlapping parent and child replay paths. Restore the regressions from react#37710, react#37850, and react#37851 and cover indexed retries and abort traversal. Replay and SuspenseList tasks retain their existing abort path until their separate completion bookkeeping supports partial progress.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the completed shell by postponing the interrupted child and unvisited siblings without running more rendering code. This addresses react#37709 without restoring overlapping parent and child replay paths. Restore the regressions from react#37710, react#37850, and react#37851 and cover indexed retries and abort traversal. Replay and SuspenseList tasks retain their existing abort path until their separate completion bookkeeping supports partial progress.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the parent segment by postponing interrupted and unvisited children, allowing the already-rendered host structure to complete. This addresses react#37709 without overlapping parent and child replay paths. Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries and abort traversal. A component may finish its render-phase updates after abort, but its returned children are discarded before they enter the model. Replay and SuspenseList rows retain their existing completion handling.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the parent segment by postponing interrupted and unvisited children, allowing the already-rendered host structure to complete. This addresses react#37709 without overlapping parent and child replay paths. Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries and abort traversal. A component may finish its render-phase updates after abort, but its returned children are discarded before they enter the model. Replay and SuspenseList rows retain their existing completion handling.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the parent segment by postponing interrupted and unvisited children, allowing the already-rendered host structure to complete. This addresses react#37709 without overlapping parent and child replay paths. Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries and abort traversal. A component may finish its render-phase updates after abort, but its returned children are discarded before they enter the model. Replay and SuspenseList rows retain their existing completion handling.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the parent segment by postponing interrupted and later component work while allowing existing text and host elements to complete. This addresses react#37709 without overlapping parent and child replay paths. Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries, static host children after abort, and abort traversal. A component may finish its render-phase updates after abort, but its returned children are discarded before they enter the model. Replay and SuspenseList rows retain their existing completion handling.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Keep the parent segment and postpone individual nodes whose user code returns after abort while allowing existing text and host elements to complete. This addresses react#37709 without overlapping parent and child replay paths. Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries, static host children, callback results, and abort traversal. Render-phase updates may finish after abort, but their returned children are discarded before entering the model. SuspenseList rows retain their separate completion handling.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Keep the parent segment and postpone individual nodes whose user code returns after abort while allowing existing text and host elements to complete. This addresses react#37709 without overlapping parent and child replay paths. Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries, static host children, callback results, and abort traversal. Render-phase updates may finish after abort, but their returned children are discarded before entering the model. SuspenseList rows retain their separate completion handling.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Keep the parent segment and postpone individual nodes whose user code returns after abort while allowing existing text and host elements to complete. This addresses react#37709 without overlapping parent and child replay paths. Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries, static host children, callback results, and abort traversal. Render-phase updates may finish after abort, but their returned children are discarded before entering the model. SuspenseList rows retain their separate completion handling.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Keep the parent segment and postpone individual nodes whose user code returns after abort while allowing existing text and host elements to complete. This addresses react#37709 without overlapping parent and child replay paths. Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries, static host children, callback results, and abort traversal. Render-phase updates may finish after abort, but their returned children are discarded before entering the model. SuspenseList rows retain their separate completion handling.
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Keep the parent segment and postpone individual nodes whose user code returns after abort while allowing existing text and host elements to complete. This addresses react#37709 without overlapping parent and child replay paths. Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries, static host children, callback results, and abort traversal. Render-phase updates may finish after abort, but their returned children are discarded before entering the model. SuspenseList rows retain their separate completion handling.
The regression from react#37710 asserts that resuming after an abort during a retried task preserves its parent markup. Name the test after that observable behavior rather than the reverted fix's strategy of resuming the task from where it started.
#37709 showed that a synchronous prerender abort can discard a retried task's rendered shell, then resume only an inner slot. #37710 addressed the missing markup by postponing the whole task, but that could overlap replay paths from child tasks; #37852 reverted that approach. Preserve the parent segment and continue rendering its text and host elements after abort. When a component or other render callback returns after abort, discard its children and track a postponed hole at that node. This includes function and class components, lazy and forward-ref components, Context.Consumer render props, iterables, and thenables. Already-created arrays are read normally; getters and host prop serialization follow React's render-purity rules. SuspenseList rows use the same postponement path and existing row task bookkeeping. Preserve individual holes only while rendering an unfinished Suspense boundary. Tasks without a blocked boundary unwind through the existing root abort path: a postponed root cannot flush any shell and must render again in full. Tests cover root aborts during the initial render, in a retried child, and during a subsequent resumeAndPrerender, followed by a complete final resume. This restores the tests from #37710, #37850, and #37851 and adds coverage for indexed retries, static host children after abort, iterators and thenables, forward refs, render-phase updates, nested fallbacks, and SuspenseList rows. A full-flow regression for repeated aborts during resumeAndPrerender is marked `it.failing`: it exposes an existing bug in postponing an already emitted boundary, fixed separately in #37876. The browser prerender suite passes in development and production on stable and experimental channels, including the expected failure. ESLint and Prettier pass.
#37709 showed that a synchronous prerender abort can discard a retried task's rendered shell, then resume only an inner slot. #37710 addressed the missing markup by postponing the whole task, but that could overlap replay paths from child tasks; #37852 reverted that approach. Preserve the parent segment and continue rendering its text and host elements after abort. When a component or other render callback returns after abort, discard its children and track a postponed hole at that node. This includes function and class components, lazy and forward-ref components, Context.Consumer render props, iterables, and thenables. Already-created arrays are read normally; getters and host prop serialization follow React's render-purity rules. SuspenseList rows use the same postponement path and existing row task bookkeeping. Preserve individual holes only while rendering an unfinished Suspense boundary. Tasks without a blocked boundary unwind through the existing root abort path: a postponed root cannot flush any shell and must render again in full. Tests cover root aborts during the initial render, in a retried child, and during a subsequent resumeAndPrerender, followed by a complete final resume. This restores the tests from #37710, #37850, and #37851 and adds coverage for indexed retries, static host children after abort, iterators and thenables, forward refs, render-phase updates, nested fallbacks, and SuspenseList rows. A full-flow regression for repeated aborts during resumeAndPrerender is marked `it.failing`: it exposes an existing bug in postponing an already emitted boundary, fixed separately in #37876. The browser prerender suite passes in development and production on stable and experimental channels, including the expected failure. ESLint and Prettier pass. DiffTrain build for [ba39b32](ba39b32)
Summary
Fixes #37709
When a prerender is aborted while a retried render task is on the stack,
retryRenderTaskresets the segment to where the attempt started, buttask.keyPathandtask.childIndexare left at the innermost child that was rendering.abortUnwoundTaskthen postpones the task at that child's slot under its parent element, and the resume renders only that child into the boundary's segment.This restores the key path and child index the attempt started from before finishing the abort, so the postponed hole covers the whole discarded attempt.
task.nodestays as is, since DEV async debug info reads it for the owner stack.How did you test this change?
The first commit adds a test to
ReactDOMFizzStaticBrowser-testthat aborts the prerender from a component rendered by a retried task and resumes it, asserting the current output (<div>World</div>). The second commit is the fix and updates the assertion to the whole<section>.yarn test packages/react-dom/src/__tests__/ReactDOMFizz packages/react-serverpasses with and without-r=experimental. With--prod,ReactServer › has Owner Stacks in DEV when abortedfails the same way on main. Prettier, ESLint andyarn flow dom-nodeare clean.