Skip to content

Conversation

brophdawg11
Copy link
Contributor

@brophdawg11 brophdawg11 commented Sep 8, 2022

We need to send the AbortedDeferredError through the TrackedPromise in _error so Await can throw a never-resolving promise to Suspense to freeze the UI. Otherwise, we end up throwing an already-rejected promise to Suspense, which sends it right back down to Await. React does break out of this loop as soon as the next load or navigation finishes, but it's busted during the transition

@changeset-bot
Copy link

changeset-bot bot commented Sep 8, 2022

🦋 Changeset detected

Latest commit: 6a01fec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
react-router Patch
@remix-run/router Patch
react-router-dom Patch
react-router-dom-v5-compat Patch
react-router-native Patch

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++;
Copy link
Contributor Author

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>
Copy link
Contributor Author

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);
Copy link
Contributor Author

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

@brophdawg11 brophdawg11 merged commit 112c02c into dev Sep 8, 2022
@brophdawg11 brophdawg11 deleted the brophdawg11/abort-defer-loop branch September 8, 2022 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants