Wrong execution order - generateMetadata + Page.
Unanswered
omermanman posted this in #help-forum
I see in a page with
Which seems to me like a big issue/bug/regression. I have a notFound invokation in my generateMetadata, and its called but the page already starts and it throws an error(which shouldnt of been invoked) is there a known issue for that?
"next": "15.2.0-canary.65"
"react": "19.1.0-canary-a84862db-20250218"
Help? 🙏
async generateMetadata
and async default Page
, that the generateMetadata method starts AFTER the page.Which seems to me like a big issue/bug/regression. I have a notFound invokation in my generateMetadata, and its called but the page already starts and it throws an error(which shouldnt of been invoked) is there a known issue for that?
"next": "15.2.0-canary.65"
"react": "19.1.0-canary-a84862db-20250218"
Help? 🙏
8 Replies
Hi,
Nextjs introduce recently: https://nextjs.org/blog/next-15-2#streaming-metadata
You may have it enable on your canary version
Which seems to me like a big issue/bug/regressionWhat issue do you have?
Nextjs introduce recently: https://nextjs.org/blog/next-15-2#streaming-metadata
You may have it enable on your canary version
Thank you so much for the fast response!
If it's the default behavior, then it seems to describe my issue exactly! It might just be it, and I'll handle it accordingly, thank you (If it's a flag, then no Im certein I dont have it on in my config)
If it's the default behavior, then it seems to describe my issue exactly! It might just be it, and I'll handle it accordingly, thank you (If it's a flag, then no Im certein I dont have it on in my config)
Im using notFound as part of my generateMetadata, and I used to trust that it happens before the page starts, so no need to worry if my page assumes some varaibles are present because if they weren't then I could just trust that 404 will be thrown
In any case Im guessing that its happening because of this 15.2 streaming metadata update it seems right. but if it's something that requires my explicit enable, then it still might be a bug because I most certenly does not have it on
Yeah seems to be it!
Looking at the releases, it seems like there is a PR for that use case: https://github.com/vercel/next.js/pull/76156
You may want to look to upgrade to the latest stable ?
Looking at the releases, it seems like there is a PR for that use case: https://github.com/vercel/next.js/pull/76156
You may want to look to upgrade to the latest stable ?
I will update and report back soon thank you so much Julienng!
Well I ended up having the notFound code on both the Page and the generateMetadata 🤷
Oh weird ! Maybe you can create an issue on the nextjs repo with an example of the expected behavior ?