-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
19e025f
to
73954db
Compare
73954db
to
5a1e378
Compare
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; |
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.
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.
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.
But really if we did encode Halt like we do Postpone as a separate row then they would be even more similar.
5a1e378
to
615833a
Compare
8e9c567
to
bb2eb26
Compare
onAllReady: () => void, | ||
onFatalError: mixed => void, | ||
onAllReady: void | (() => void), | ||
onFatalError: void | (mixed => void), |
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.
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.
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.
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.
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.
Which means that we probably need to add another field then.
bb2eb26
to
3e9c0cf
Compare
6a6ec1b
to
6340525
Compare
// 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)); |
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.
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.
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.
Ideally we wouldn't generate an error id in the halting case but it's unobservable so doesn't block.
6340525
to
3fd8dcb
Compare
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.
3fd8dcb
to
cf8d1d1
Compare
**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 facebook/react@1eaccd82...eb3ad065](facebook/react@1eaccd8...eb3ad06) <details> <summary>React upstream changes</summary> - facebook/react#30761 - facebook/react#30779 - facebook/react#30775 - facebook/react#30770 - facebook/react#30756 - facebook/react#30755 - facebook/react#30768 - facebook/react#30760 - facebook/react#30732 - facebook/react#30757 - facebook/react#30750 - facebook/react#30751 - facebook/react#30753 - facebook/react#30740 - facebook/react#30748 - facebook/react#30746 - facebook/react#30747 - facebook/react#30731 - facebook/react#30725 - facebook/react#30741 - facebook/react#30730 - facebook/react#30726 - facebook/react#30717 - facebook/react#30729 - facebook/react#30721 - facebook/react#30720 - facebook/react#30705 </details>
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.