Skip to content

Remove defer implementation in favor of raw promises #11744

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

Merged
merged 4 commits into from
Jul 1, 2024

Conversation

brophdawg11
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Jun 27, 2024

🦋 Changeset detected

Latest commit: 5721631

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

This PR includes changesets to release 6 packages
Name Type
react-router-dom Major
react-router Major
@react-router/dev Major
@react-router/express Major
@react-router/node Major
@react-router/serve Major

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

@brophdawg11 brophdawg11 force-pushed the brophdawg11/remove-defer-impl branch from 4aaa8a8 to 9312705 Compare June 28, 2024 14:41
Comment on lines -358 to -363
resolvedUndefined: new Promise(
(resolve) => setTimeout(() => {
resolve(undefined);
}, 10)
),
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's fine to resolve with undefined now so removed this aspect of the test

@@ -566,23 +532,6 @@ test.describe("non-aborted", () => {
);
}
`,

"app/routes/headers.tsx": js`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Headers aren't special to defer anymore and are tested elsewhere

Comment on lines -623 to +572
test("resolved promises render in initial payload", async ({ page }) => {
test("resolved promises do not render in initial payload", async ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without defer we no longer render resolved promises in the initial shell

Comment on lines -1939 to -1943
cancelActiveDeferreds(
(routeId) =>
!(matches && matches.some((m) => m.route.id === routeId)) ||
(matchesToLoad && matchesToLoad.some((m) => m.route.id === routeId))
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be up to users to abort their own promises going forward

Comment on lines -2060 to -2069
activeDeferreds.forEach((deferredData, routeId) => {
deferredData.subscribe((aborted) => {
// Note: No need to updateState here since the TrackedPromise on
// loaderData is stable across resolve/reject
// Remove this instance if we were aborted or if promises have settled
if (aborted || deferredData.done) {
activeDeferreds.delete(routeId);
}
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer needed - promises will settle and be handled in the UI by application code

@brophdawg11 brophdawg11 marked this pull request as ready for review June 28, 2024 14:48
@brophdawg11 brophdawg11 added the v7 label Jun 28, 2024
@brophdawg11 brophdawg11 merged commit 0457dbe into v7 Jul 1, 2024
5 checks passed
@brophdawg11 brophdawg11 deleted the brophdawg11/remove-defer-impl branch July 1, 2024 14:41
Copy link
Contributor

🤖 Hello there,

We just published version 6.28.2-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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