-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
fix: prevent aborted defer values from starting a suspense render loop #9226
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
Conversation
🦋 Changeset detectedLatest commit: 6a01fec The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
} | ||
|
||
function AwaitCounter({ data }) { | ||
awaitRenderCount++; |
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.
Leveraging this to assert that we aren't continually re-rendering during the transition that triggered the abort
href=\\"/bar\\" | ||
> | ||
Link to Bar | ||
</a> |
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.
Shrunk the area of the DOM we were asserting in existing tests since I added a new link to /baz
`); | ||
// 2 more renders by now - once for the navigation and once for the | ||
// promise abort rejection | ||
expect(getAwaitRenderCount()).toBe(3); |
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 the loop is present this goes much higher than 3
We need to send the
AbortedDeferredError
through theTrackedPromise
in_error
soAwait
can throw a never-resolving promise toSuspense
to freeze the UI. Otherwise, we end up throwing an already-rejected promise toSuspense
, which sends it right back down toAwait
. React does break out of this loop as soon as the next load or navigation finishes, but it's busted during the transition