-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix static to dynamic error in dev (#46597)
This corrects the static to dynamic error incorrectly showing in development since we don't have enough information to accurately know if this error should be thrown or not unless a build has been done. Fixes: #46436 x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1677637140906959) ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
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
35 changes: 35 additions & 0 deletions
35
test/e2e/app-dir/app-static/app/gen-params-dynamic/[slug]/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,35 @@ | ||
export async function generateStaticParams() { | ||
return [{ slug: 'one' }] | ||
} | ||
|
||
const fetchRetry = async (url, init) => { | ||
for (let i = 0; i < 5; i++) { | ||
try { | ||
return await fetch(url, init) | ||
} catch (err) { | ||
if (i === 4) { | ||
throw err | ||
} | ||
console.log(`Failed to fetch`, err, `retrying...`) | ||
} | ||
} | ||
} | ||
|
||
export default async function page({ params }) { | ||
const { slug } = params | ||
const data = await fetchRetry( | ||
'https://next-data-api-endpoint.vercel.app/api/random', | ||
{ | ||
method: 'POST', | ||
body: JSON.stringify({ hello: 'world' }), | ||
} | ||
).then((res) => res.text()) | ||
|
||
return ( | ||
<> | ||
<p id="page">/gen-params-dynamic/[slug]</p> | ||
<p id="slug">{slug}</p> | ||
<p id="data">{data}</p> | ||
</> | ||
) | ||
} |