-
Notifications
You must be signed in to change notification settings - Fork 27.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Page being prerendered with broken parameters, and pages in app dir not actually pre-prendered even with generateStaticParams #45235
Comments
@vattenapa hopefully this will get a second look |
Please try moving your export const generateStaticParams = async () => {
return ['test','apple', 'orange'];
}; But you have to modify it to look like: export const generateStaticParams = async () => {
return [
{id: 'test'}, {id: 'apple'}, {id: 'orange'}
]
}; because the |
OK, now my real (well, for fun) next site is generating 10000 pages again. Thanks! For anyone that finds this, this is the fix: It looks like things are far closer to the pages than I thought. Might be valuable to to flag a page that exports |
On my real (no work) site, after the fixes, I still see one Is there a way to track this down? A way to have next use non-minified files because the trace is ugly:
|
Oh, never mind. I have another that is dynamic only but not marked as such, and there is no generateStaticParams but it does get generated since it is not marked as dynamic only, and I guess sending that dummy data is a way to tell that page something? |
What about when
What's the expected behavior in that case? |
@FranciscoMoretti I have the same problem and it addind Edit : It is pretty annoying because I cannot deploy to Vercel without having to filter out this garbage value |
This condition seems really confusing to me: https://github.com/vercel/next.js/blob/canary/packages/next/src/build/index.ts#L1288-L1292 I would say we never want to add a Dynamic route page in the appStaticPaths. I would change the condition to :
With this the build seems ok on my side |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Data fetching (gS(S)P, getInitialProps)
Link to the code that reproduces this issue
https://github.com/sroussey/test-build/tree/generateStaticParams
To Reproduce
Notice the extra stuff in build output in the terminal from a console.error. It is showing the parameters during the build -- and they are the values of
id
, but instead the encoded string[id]
as `` as a literal!Instead of the page being generated three times with the values of
['test','apple', 'orange']
the AppTestDetailPage is instead called twice (btw, if the array of values fromgenerateStaticParams
is longer, it always gets called exactly twice, regardless) with arguments of{ params: { id: '%5Bid%5D' }, searchParams: { id: '[id]' } }
.Describe the Bug
In version 13.1.1 there is no output at all from console.error in AppTestDetailPage. It is never called. This bug where it gets sent bad data started in 13.1.2.
If you put in
export const dynamic = 'force-dynamic'
the issue goes away (as expected). I want'force-static'
or'auto'
so the app pages get rendered at build time.At this point, I have somewhat gone through related issue #45220.
Now the bigger deal... I don't think the app pages are pre-rendered at build time at all.
The big clue is that the AppTestDetailPage's console messages are not generated at all for the values found in
generateStaticParams
.The other clue is that the build output in the terminal shows the sub-pages for the pages directory, but nothing like that for the exact same thing done in the app directory.
For pages:
but for app:
There is no
/app/test
,/app/apple
, or/app/orange
.Another clue is in
.next/prerender-manifest.json
-- you can find/pages/apple
but not/app/apple
The next clue is looking at
.next/server/pages
and you seeapple.html
etc. But when you look in.next/server/app
there are no such html files.Expected Behavior
{ id: '%5Bid%5D' }
) to be passed to the pre-rendered pageWhich browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: