GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Flight][Static] Implement halting a prerender behind enableHalt by gnoff · Pull Request #30705 · react/react

Conversation

@gnoff

@gnoff gnoff commented Aug 15, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

enableHalt turns on a mode for flight prerenders where aborts are treated like infinitely stalled outcomes while still completing the prerender. For regular tasks we simply serialize the slot as a promise that never settles. For ReadableStream, Blob, and Async Iterators we just never advance the serialization so they remain unfinished when consumed on the client.

When enableHalt is turned on aborts of prerenders will halt rather than error. The abort reason is forwarded to the upstream produces of the aforementioned async iterators, blobs, and ReadableStreams. In the future if we expose a signal that you can consume from within a render to cancel additional work the abort reason will also be forwarded there

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vercel

vercel Bot commented Aug 15, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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 16, 2024 8:58pm
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Aug 15, 2024
@vercel
vercel Bot deployed to Preview August 15, 2024 05:32
View deployment
@react-sizebot

react-sizebot commented Aug 15, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 1eaccd8285f0bd40407705a9356391a171adf3b1...392b9c8ad08be6893878420d65e5cb5bf96f4ac3

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 +0.11% 1.82 kB 1.83 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 +0.05% 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
oss-experimental/react-server/cjs/react-server-flight.production.js +3.38% 60.96 kB 63.02 kB +1.88% 12.20 kB 12.43 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +2.37% 101.32 kB 103.72 kB +1.54% 18.60 kB 18.88 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +2.04% 92.82 kB 94.71 kB +1.09% 19.19 kB 19.40 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-server/cjs/react-server-flight.production.js +3.38% 60.96 kB 63.02 kB +1.88% 12.20 kB 12.43 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +2.37% 101.32 kB 103.72 kB +1.54% 18.60 kB 18.88 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +2.04% 92.82 kB 94.71 kB +1.09% 19.19 kB 19.40 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +1.97% 95.99 kB 97.89 kB +1.37% 19.48 kB 19.75 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +1.97% 96.31 kB 98.20 kB +1.37% 19.57 kB 19.84 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +1.96% 96.41 kB 98.31 kB +1.41% 19.59 kB 19.87 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +1.96% 96.44 kB 98.34 kB +1.41% 19.59 kB 19.87 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +1.92% 98.47 kB 100.37 kB +1.04% 20.07 kB 20.28 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +1.92% 98.49 kB 100.39 kB +1.04% 20.07 kB 20.28 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +1.90% 99.43 kB 101.32 kB +1.37% 20.28 kB 20.55 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +1.90% 99.46 kB 101.36 kB +1.37% 20.27 kB 20.55 kB
oss-stable-rc/react-server/cjs/react-server-flight.production.js +1.78% 56.88 kB 57.89 kB +0.98% 11.48 kB 11.59 kB
oss-stable-semver/react-server/cjs/react-server-flight.production.js +1.78% 56.88 kB 57.89 kB +0.98% 11.48 kB 11.59 kB
oss-stable/react-server/cjs/react-server-flight.production.js +1.78% 56.88 kB 57.89 kB +0.98% 11.48 kB 11.59 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.66% 143.76 kB 146.14 kB +1.23% 26.48 kB 26.81 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +1.63% 146.67 kB 149.06 kB +1.17% 26.87 kB 27.18 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +1.62% 147.29 kB 149.67 kB +1.15% 27.05 kB 27.36 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +1.60% 149.51 kB 151.90 kB +1.19% 27.24 kB 27.56 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +1.59% 149.66 kB 152.05 kB +1.19% 27.30 kB 27.63 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +1.59% 150.12 kB 152.51 kB +1.14% 27.47 kB 27.78 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1.59% 150.28 kB 152.67 kB +1.14% 27.53 kB 27.84 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +1.58% 151.24 kB 153.62 kB +1.14% 27.73 kB 28.05 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +1.58% 151.38 kB 153.77 kB +1.14% 27.80 kB 28.12 kB
oss-stable-rc/react-server/cjs/react-server-flight.development.js +1.23% 86.79 kB 87.85 kB +0.71% 16.10 kB 16.22 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +1.23% 86.79 kB 87.85 kB +0.71% 16.10 kB 16.22 kB
oss-stable/react-server/cjs/react-server-flight.development.js +1.23% 86.79 kB 87.85 kB +0.71% 16.10 kB 16.22 kB
oss-experimental/react-markup/cjs/react-markup.react-server.production.js +0.34% 300.55 kB 301.58 kB +0.26% 56.84 kB 56.98 kB
oss-experimental/react-markup/cjs/react-markup.react-server.development.js +0.30% 497.97 kB 499.45 kB +0.33% 89.64 kB 89.93 kB

Generated by 🚫 dangerJS against 29572d9

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gnoff
gnoff force-pushed the prerender-infinite-promise-on-abort branch 2 times, most recently from f953493 to 398aa80 Compare August 15, 2024 05:37
@vercel
vercel Bot deployed to Preview August 15, 2024 05:41
View deployment
@gnoff
gnoff force-pushed the prerender-infinite-promise-on-abort branch from 398aa80 to ab5b304 Compare August 15, 2024 22:02
@vercel
vercel Bot deployed to Preview August 15, 2024 22:07
View deployment
@gnoff
gnoff force-pushed the prerender-infinite-promise-on-abort branch from ab5b304 to 43e51e0 Compare August 16, 2024 05:47
@vercel
vercel Bot deployed to Preview August 16, 2024 05:49
View deployment
@gnoff
gnoff force-pushed the prerender-infinite-promise-on-abort branch from 43e51e0 to 1227997 Compare August 16, 2024 05:51
@vercel
vercel Bot deployed to Preview August 16, 2024 05:53
View deployment
@gnoff
gnoff marked this pull request as ready for review August 16, 2024 05:53
@gnoff
gnoff force-pushed the prerender-infinite-promise-on-abort branch from 1227997 to c93a575 Compare August 16, 2024 06:10
@gnoff gnoff changed the title [Flight][Static] When prerendering serialize infinite promise when aborting with no reason [Flight][Static] Implement halting a prerender behind enableHalt Aug 16, 2024
@vercel
vercel Bot deployed to Preview August 16, 2024 06:12
View deployment
@gnoff
gnoff force-pushed the prerender-infinite-promise-on-abort branch from c93a575 to 9e45ae9 Compare August 16, 2024 06:22
@vercel
vercel Bot deployed to Preview August 16, 2024 06:24
View deployment
@gnoff
gnoff force-pushed the prerender-infinite-promise-on-abort branch 3 times, most recently from ba510dd to 5a91fee Compare August 16, 2024 06:35
@gnoff
gnoff requested a review from sebmarkbage August 16, 2024 06:39
@vercel
vercel Bot deployed to Preview August 16, 2024 06:39
View deployment
sebmarkbage
sebmarkbage approved these changes Aug 16, 2024
View reviewed changes

@sebmarkbage sebmarkbage left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It feels a little unnecessary/hacky to introduce another object kind with duck-typing especially if postpone is going away and then ideally thrown promises go away too.

How about instead we store the reason on the request like we do for fatalError and use it if we're in the halting status. It can even be the same slot with a different status (we already abuse it for aborting in the same way).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnoff

gnoff commented Aug 16, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

@sebmarkbage

How about instead we store the reason on the request like we do for fatalError and use it if we're in the halting status.

We are currently using that slot for the ref id. I could instead just always emit an infinite promise into those slots instead though rather than referring to the a shared one since it's basically the same size

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gnoff
gnoff force-pushed the prerender-infinite-promise-on-abort branch from 5a91fee to c891489 Compare August 16, 2024 20:50
@vercel
vercel Bot deployed to Preview August 16, 2024 20:52
View deployment
@gnoff
[Flight][Static] Implement halting a prerender behind enableHalt
29572d9
enableHalt turns on a mode for flight prerenders where aborts are treated like infinitely stalled outcomes while still completing the prerender. For regular tasks we simply serialize the slot as a promise that never settles. For ReadableStream, Blob, and Async Iterators we just never advance the serialization so they remain unfinished when consumed on the client.

When enableHalt is turned on aborts of prerenders will halt rather than error. The abort reason is forwarded to the upstream produces of the aforementioned async iterators, blobs, and ReadableStreams. In the future if we expose a signal that you can consume from within a render to cancel additional work the abort reason will also be forwarded there
@gnoff
gnoff force-pushed the prerender-infinite-promise-on-abort branch from c891489 to 29572d9 Compare August 16, 2024 20:56
@vercel
vercel Bot deployed to Preview August 16, 2024 20:58
View deployment
@gnoff
gnoff merged commit 7b41cdc into react:main Aug 16, 2024
@gnoff
gnoff deleted the prerender-infinite-promise-on-abort branch August 16, 2024 21:22
sebmarkbage
sebmarkbage reviewed Aug 16, 2024
View reviewed changes
Comment thread packages/react-server/src/ReactFlightServer.js
function serializeInfinitePromise(): string {
return '$@';
}
const reusableInfinitePromiseModel = stringify(serializeInfinitePromise());

@sebmarkbage sebmarkbage Aug 16, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Does this get inlined btw? Might as well just hard code the string to ensure it does. There's not really any purpose in having it be hoisted value since it'll be interned anyway.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sebmarkbage
sebmarkbage reviewed Aug 17, 2024
View reviewed changes
Comment thread packages/react-server/src/ReactFlightServer.js
if (request.status === ABORTING) {
task.status = ABORTED;
if (enableHalt && request.fatalError === haltSymbol) {
return serializeInfinitePromise();

@sebmarkbage sebmarkbage Aug 17, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

So I don't think this is actually right. Because this is saying that this value will be a Promise but if this wasn't already a Promise that's incorrect. It's not the same as postpone which gets serialized as an error. What you want here is more like serializeByValueID to an ID that will never resolve.

The only time you can use serializeInfinitePromise() is when you're actually serializing a Promise/Thenable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnoff gnoff mentioned this pull request Aug 17, 2024
[Flight] model halted references explicitly #30731
Merged
gnoff added a commit that referenced this pull request Aug 19, 2024
@gnoff
[Flight] model halted references explicitly (#30731)
9d082b5
using infinitely suspending promises isn't right because this will parse
as a promise which is only appropriate if the value we're halting at is
a promise. Instead we need to have a special marker type that says this
reference will never resolve. Additionally flight client needs to not
error any halted references when the stream closes because they will
otherwise appear as an error

addresses:
#30705 (comment)
@eps1lon eps1lon mentioned this pull request Aug 22, 2024
Update React from 1eaccd82-20240816 to eb3ad065-20240822 vercel/next.js#69196
Merged
eps1lon added a commit to vercel/next.js that referenced this pull request Aug 23, 2024
@eps1lon
Update React from 1eaccd82-20240816 to eb3ad065-20240822 (#69196)
6c09bd9
**breaking change for canary users: Bumps peer dependency of React from
`19.0.0-rc-1eaccd82-20240816` to `19.0.0-rc-eb3ad065-20240822`**

No changes required in Next.js it seems.

[diff
react/react@1eaccd82...eb3ad065](react/react@1eaccd8...eb3ad06)
<details>
<summary>React upstream changes</summary>

- react/react#30761
- react/react#30779
- react/react#30775
- react/react#30770
- react/react#30756
- react/react#30755
- react/react#30768
- react/react#30760
- react/react#30732
- react/react#30757
- react/react#30750
- react/react#30751
- react/react#30753
- react/react#30740
- react/react#30748
- react/react#30746
- react/react#30747
- react/react#30731
- react/react#30725
- react/react#30741
- react/react#30730
- react/react#30726
- react/react#30717
- react/react#30729
- react/react#30721
- react/react#30720
- react/react#30705

</details>
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@gnoff
[Flight][Static] Implement halting a prerender behind enableHalt (rea…
f397aa5
…ct#30705)

enableHalt turns on a mode for flight prerenders where aborts are
treated like infinitely stalled outcomes while still completing the
prerender. For regular tasks we simply serialize the slot as a promise
that never settles. For ReadableStream, Blob, and Async Iterators we
just never advance the serialization so they remain unfinished when
consumed on the client.

When enableHalt is turned on aborts of prerenders will halt rather than
error. The abort reason is forwarded to the upstream produces of the
aforementioned async iterators, blobs, and ReadableStreams. In the
future if we expose a signal that you can consume from within a render
to cancel additional work the abort reason will also be forwarded there
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@gnoff
[Flight] model halted references explicitly (react#30731)
ca0e9c3
using infinitely suspending promises isn't right because this will parse
as a promise which is only appropriate if the value we're halting at is
a promise. Instead we need to have a special marker type that says this
reference will never resolve. Additionally flight client needs to not
error any halted references when the stream closes because they will
otherwise appear as an error

addresses:
react#30705 (comment)

This branch was successfully deployed

1 active deployment
Preview — 29572d94 Deployed Aug 16, 2024 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@sebmarkbage sebmarkbage sebmarkbage approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@gnoff @react-sizebot @sebmarkbage @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.