Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flight] model halting as never delivered chunks #30740

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

gnoff
Copy link
Collaborator

@gnoff gnoff commented Aug 17, 2024

stacked on: #30731

We've refined the model of halting a prerender. Now when you abort during a prerender we simply omit the rows that would complete the flight render. This is analagous to prerendering in Fizz where you must resume the prerender to actually result in errors propagating in the postponed holes. We don't have a resume yet for flight and it's not entirely clear how that will work however the key insight here is that deciding whether the never resolving rows are an error or not should really be done on the consuming side rather than in the producer.

This PR also reintroduces the logs for the abort error/postpone when prerendering which will give you some indication that something wasn't finished when the prerender was aborted.

Copy link

vercel bot commented Aug 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 20, 2024 2:31am

@react-sizebot
Copy link

react-sizebot commented Aug 17, 2024

Comparing: 0fa9476...9ae9a21

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.68 kB 6.68 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 500.37 kB 500.37 kB = 89.80 kB 89.80 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 507.50 kB 507.50 kB = 90.96 kB 90.96 kB
facebook-www/ReactDOM-prod.classic.js = 595.24 kB 595.24 kB = 105.55 kB 105.55 kB
facebook-www/ReactDOM-prod.modern.js = 571.54 kB 571.54 kB = 101.75 kB 101.75 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-rc/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +1.20% 87.89 kB 88.94 kB +0.40% 18.32 kB 18.39 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +1.20% 87.89 kB 88.94 kB +0.40% 18.32 kB 18.39 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +1.20% 87.89 kB 88.94 kB +0.40% 18.32 kB 18.39 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +1.15% 91.04 kB 92.09 kB +0.33% 18.73 kB 18.79 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +1.15% 91.04 kB 92.09 kB +0.33% 18.73 kB 18.79 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +1.15% 91.04 kB 92.09 kB +0.33% 18.73 kB 18.79 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +1.15% 91.36 kB 92.41 kB +0.33% 18.82 kB 18.88 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +1.15% 91.36 kB 92.41 kB +0.33% 18.82 kB 18.88 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +1.15% 91.36 kB 92.41 kB +0.33% 18.82 kB 18.88 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +1.15% 91.38 kB 92.43 kB +0.32% 18.84 kB 18.90 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +1.15% 91.38 kB 92.43 kB +0.32% 18.84 kB 18.90 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +1.15% 91.38 kB 92.43 kB +0.32% 18.84 kB 18.90 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +1.15% 91.41 kB 92.45 kB +0.32% 18.83 kB 18.89 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +1.15% 91.41 kB 92.45 kB +0.32% 18.83 kB 18.89 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +1.15% 91.41 kB 92.45 kB +0.32% 18.83 kB 18.89 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +1.12% 93.55 kB 94.60 kB +0.31% 19.21 kB 19.27 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +1.12% 93.55 kB 94.60 kB +0.31% 19.21 kB 19.27 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +1.12% 93.55 kB 94.60 kB +0.31% 19.21 kB 19.27 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +1.12% 93.56 kB 94.62 kB +0.31% 19.21 kB 19.27 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +1.12% 93.56 kB 94.62 kB +0.31% 19.21 kB 19.27 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +1.12% 93.56 kB 94.62 kB +0.31% 19.21 kB 19.27 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +1.11% 94.50 kB 95.55 kB +0.33% 19.41 kB 19.48 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +1.11% 94.50 kB 95.55 kB +0.33% 19.41 kB 19.48 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +1.11% 94.50 kB 95.55 kB +0.33% 19.41 kB 19.48 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +1.11% 94.53 kB 95.58 kB +0.32% 19.41 kB 19.47 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +1.11% 94.53 kB 95.58 kB +0.32% 19.41 kB 19.47 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +1.11% 94.53 kB 95.58 kB +0.32% 19.41 kB 19.47 kB
oss-stable-rc/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.93% 127.57 kB 128.75 kB +0.28% 23.81 kB 23.87 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.93% 127.57 kB 128.75 kB +0.28% 23.81 kB 23.87 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.93% 127.57 kB 128.75 kB +0.28% 23.81 kB 23.87 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.90% 131.32 kB 132.50 kB +0.31% 24.42 kB 24.49 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.90% 131.32 kB 132.50 kB +0.31% 24.42 kB 24.49 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.90% 131.32 kB 132.50 kB +0.31% 24.42 kB 24.49 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.90% 131.94 kB 133.13 kB +0.33% 24.61 kB 24.69 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.90% 131.94 kB 133.13 kB +0.33% 24.61 kB 24.69 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.90% 131.94 kB 133.13 kB +0.33% 24.61 kB 24.69 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.89% 132.53 kB 133.71 kB +0.28% 24.64 kB 24.71 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.89% 132.53 kB 133.71 kB +0.28% 24.64 kB 24.71 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.89% 132.53 kB 133.71 kB +0.28% 24.64 kB 24.71 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.89% 132.68 kB 133.86 kB +0.28% 24.71 kB 24.78 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.89% 132.68 kB 133.86 kB +0.28% 24.71 kB 24.78 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.89% 132.68 kB 133.86 kB +0.28% 24.71 kB 24.78 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.88% 133.94 kB 135.12 kB +0.27% 24.78 kB 24.84 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.88% 133.94 kB 135.12 kB +0.27% 24.78 kB 24.84 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.88% 133.94 kB 135.12 kB +0.27% 24.78 kB 24.84 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.88% 134.10 kB 135.28 kB +0.27% 24.84 kB 24.91 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.88% 134.10 kB 135.28 kB +0.27% 24.84 kB 24.91 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.88% 134.10 kB 135.28 kB +0.27% 24.84 kB 24.91 kB
oss-stable-rc/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.88% 135.05 kB 136.24 kB +0.27% 25.06 kB 25.12 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.88% 135.05 kB 136.24 kB +0.27% 25.06 kB 25.12 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.88% 135.05 kB 136.24 kB +0.27% 25.06 kB 25.12 kB
oss-stable-rc/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.88% 135.20 kB 136.38 kB +0.27% 25.12 kB 25.19 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.88% 135.20 kB 136.38 kB +0.27% 25.12 kB 25.19 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.88% 135.20 kB 136.38 kB +0.27% 25.12 kB 25.19 kB
oss-experimental/react-server/cjs/react-server-flight.production.js +0.62% 63.36 kB 63.75 kB = 12.48 kB 12.43 kB
oss-stable-rc/react-server/cjs/react-server-flight.production.js +0.56% 58.37 kB 58.70 kB = 11.63 kB 11.60 kB
oss-stable-semver/react-server/cjs/react-server-flight.production.js +0.56% 58.37 kB 58.70 kB = 11.63 kB 11.60 kB
oss-stable/react-server/cjs/react-server-flight.production.js +0.56% 58.37 kB 58.70 kB = 11.63 kB 11.60 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +0.48% 104.61 kB 105.11 kB = 19.03 kB 19.01 kB
oss-stable-rc/react-server/cjs/react-server-flight.development.js +0.33% 88.99 kB 89.29 kB = 16.41 kB 16.37 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +0.33% 88.99 kB 89.29 kB = 16.41 kB 16.37 kB
oss-stable/react-server/cjs/react-server-flight.development.js +0.33% 88.99 kB 89.29 kB = 16.41 kB 16.37 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js = 99.54 kB 99.23 kB = 18.95 kB 18.91 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js = 98.74 kB 98.43 kB = 18.77 kB 18.73 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js = 96.94 kB 96.63 kB = 18.64 kB 18.60 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js = 96.92 kB 96.62 kB = 18.65 kB 18.61 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js = 95.56 kB 95.25 kB = 18.42 kB 18.37 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js = 94.75 kB 94.44 kB = 18.25 kB 18.21 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js = 93.33 kB 93.03 kB = 17.95 kB 17.89 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js = 90.69 kB 90.39 kB = 17.16 kB 17.12 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js = 57.54 kB 57.34 kB = 11.67 kB 11.63 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js = 90.24 kB 89.93 kB = 17.05 kB 17.00 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js = 56.85 kB 56.66 kB = 11.51 kB 11.47 kB
oss-experimental/react-client/cjs/react-client-flight.development.js = 90.00 kB 89.68 kB = 16.48 kB 16.44 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js = 88.39 kB 88.08 kB = 16.66 kB 16.61 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js = 55.14 kB 54.93 kB = 11.37 kB 11.32 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js = 55.13 kB 54.92 kB = 11.38 kB 11.34 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js = 53.98 kB 53.77 kB = 11.15 kB 11.11 kB
oss-experimental/react-client/cjs/react-client-flight.production.js = 53.65 kB 53.45 kB = 9.89 kB 9.84 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.production.js = 53.28 kB 53.08 kB = 10.99 kB 10.95 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.production.js = 52.03 kB 51.82 kB = 10.71 kB 10.67 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.js = 49.71 kB 49.51 kB = 10.17 kB 10.13 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.production.js = 49.38 kB 49.17 kB = 10.08 kB 10.04 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.js = 47.77 kB 47.56 kB = 9.71 kB 9.67 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js = 124.85 kB 124.21 kB = 29.16 kB 29.03 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.js = 78.92 kB 78.28 kB = 16.72 kB 16.60 kB

Generated by 🚫 dangerJS against cf8d1d1

const abortableTasks = request.abortableTasks;
// We have tasks to abort. We'll emit one error row and then emit a reference
// to that row from every row that's still remaining.
if (abortableTasks.size > 0) {
request.status = ABORTING;
request.pendingChunks++;
const errorId = request.nextChunkId++;
request.fatalError = errorId;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Everything from here down is the same between abort/halt. So it seems like you could just have one big utility function that does the rest instead of splitting it into various smaller helpers that might be early abstraction.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But really if we did encode Halt like we do Postpone as a separate row then they would be even more similar.

onAllReady: () => void,
onFatalError: mixed => void,
onAllReady: void | (() => void),
onFatalError: void | (mixed => void),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't follow the pattern of the others and should definitely not use void as the empty value since that can cause different hidden classes. We always use null.

But I think in this case we should probably just stick to the pattern and assign a noop so we don't have to check later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Notably there's opportunity when the passed in options get compiled that it can just compile it out to a known value. Either if it's always passed or if it is never passed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Which means that we probably need to add another field then.

@gnoff gnoff force-pushed the halt-calls-onerror branch from bb2eb26 to 3e9c0cf Compare August 19, 2024 22:00
@gnoff gnoff changed the title [Flight] When halting call onError/onPostpone [Flight] model halting as never delivered chunks Aug 19, 2024
@gnoff gnoff force-pushed the halt-calls-onerror branch 6 times, most recently from 6a6ec1b to 6340525 Compare August 19, 2024 22:13
// When prerendering with halt semantics we omit the referred to error.
request.pendingChunks++;
emitErrorChunk(request, errorId, digest, error);
}
}
abortableTasks.forEach(task => abortTask(task, request, errorId));
Copy link
Collaborator

@sebmarkbage sebmarkbage Aug 20, 2024

Choose a reason for hiding this comment

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

When halting, we should not replace the existing ids to point to a new id but it should just leave the original pending id intact and never emit anything for it. Because it is resumable from that id. In other words, we should never generate the errorId in this branch.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

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

Ideally we wouldn't generate an error id in the halting case but it's unobservable so doesn't block.

We've refined the model of halting a prerender. Now when you abort during a prerender we simply omit the rows that would complete the flight render. This is analagous to prerendering in Fizz where you must resume the prerender to actually result in errors propagating in the postponed holes. We don't have a resume yet for flight and it's not entirely clear how that will work however the key insight here is that deciding whether the never resolving rows are an error or not should really be done on the consuming side rather than in the producer.

This PR also reintroduces the logs for the abort error/postpone when prerendering which will give you some indication that something wasn't finished when the prerender was aborted.
@gnoff gnoff force-pushed the halt-calls-onerror branch from 3fd8dcb to cf8d1d1 Compare August 20, 2024 02:29
@gnoff gnoff merged commit a960b92 into facebook:main Aug 20, 2024
185 checks passed
@gnoff gnoff deleted the halt-calls-onerror branch August 20, 2024 02:34
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.

4 participants