forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace custom Thenable type with native Promises (vercel#58337)
Next.js's implementation includes a custom Thenable type based on a similar one used in React's codebase. It was used to implement a userspace equivalent of the React.use API before that API became stable, by throwing a promise-like object and tracking the status on an expando field. However, it didn't cover all the same cases and behaviors that React.use does, which led to some subtle bugs like the one fixed by @ztanner in vercel#55690. Now that React.use is stable, and we use that for suspending instead of throwing a promise, we no longer need our custom Thenable type. I've removed the type and associated functions, and updated our types to use Promise instead. Even in cases where a function does return a thenable-object rather than a native promise, like React Flight's createFromFetch, we should use TypeScript's built-in PromiseLike utility. Currently, though, we always await these objects anyway (in fetch-server-response.ts), which turns them into promises. So Promise is almost always sufficient. Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
00f5b5e
commit b425b40
Showing
16 changed files
with
70 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
packages/next/src/client/components/router-reducer/create-record-from-thenable.test.ts
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
packages/next/src/client/components/router-reducer/create-record-from-thenable.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.