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.
Fix react fetch deduping without next cache (vercel#50187)
This ensures we don't reference the wrong fetch global bypassing react's patched fetch so that it can properly fallback to react's fetch deduping when next cache is disabled for a specific fetch. x-ref: [slack thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1684518670927189?thread_ts=1682974724.765039&cid=C042LHPJ1NX) fixes: vercel#50031
- Loading branch information
Showing
6 changed files
with
98 additions
and
6 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
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: 29 additions & 0 deletions
29
test/e2e/app-dir/app-static/app/react-fetch-deduping-edge/page.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export const runtime = 'edge' | ||
|
||
export default async function Page() { | ||
const data1 = await fetch( | ||
'https://next-data-api-endpoint.vercel.app/api/random?1', | ||
{ | ||
next: { | ||
revalidate: 0, | ||
}, | ||
} | ||
).then((res) => res.text()) | ||
|
||
const data2 = await fetch( | ||
'https://next-data-api-endpoint.vercel.app/api/random?1', | ||
{ | ||
next: { | ||
revalidate: 0, | ||
}, | ||
} | ||
).then((res) => res.text()) | ||
|
||
return ( | ||
<> | ||
<p>/react-fetch-deduping</p> | ||
<p id="data-1">{data1}</p> | ||
<p id="data-2">{data2}</p> | ||
</> | ||
) | ||
} |
27 changes: 27 additions & 0 deletions
27
test/e2e/app-dir/app-static/app/react-fetch-deduping-node/page.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export default async function Page() { | ||
const data1 = await fetch( | ||
'https://next-data-api-endpoint.vercel.app/api/random?1', | ||
{ | ||
next: { | ||
revalidate: 0, | ||
}, | ||
} | ||
).then((res) => res.text()) | ||
|
||
const data2 = await fetch( | ||
'https://next-data-api-endpoint.vercel.app/api/random?1', | ||
{ | ||
next: { | ||
revalidate: 0, | ||
}, | ||
} | ||
).then((res) => res.text()) | ||
|
||
return ( | ||
<> | ||
<p>/react-fetch-deduping</p> | ||
<p id="data-1">{data1}</p> | ||
<p id="data-2">{data2}</p> | ||
</> | ||
) | ||
} |