Next.js Discord

Discord Forum

Some routes not statically generated for no obvious reason

Answered
notdisliked posted this in #help-forum
Open in Discord
Hey all, really stumped here. I'm trying to run my site as ISR, with every page generated ahead of time, and an endpoint to rebuild them on demand. I've done this before with another project of min, trying it again now. For some reason, when I generate the site, two pages are marked for dynamic (server) rendering, and it's really not clear why. Log showing this is attached to this post as a file. What's really stumping me, is that one of the pages being forced into dynamic rendering is really really simple. The /bot route is being dynamically generated, the page for that is here: https://gitlab.com/developersofxur/wtfix-server/-/blob/master/app/bot/page.tsx?ref_type=heads. But, /friends is being statically generated as expected, and it's incredibly similar in complexity: https://gitlab.com/developersofxur/wtfix-server/-/blob/master/app/friends/page.tsx?ref_type=heads. They both share the same layout, which does have some data handling in it.

I am honestly completely stuck as to what could cause this. I'm not using props anywhere in the app, just a lot of (very slow) HTTP requests and some communication with a redis server for storing some values that have to persist between launches. I really don't know why any views in the site are being marked as dynamic, let alone only some of them.

This is on the latest version of next.js and all dependencies
Answered by notdisliked
the fetch call I make to the API, I set it to no-cache at some point. it must've been for debugging, but I forgot about it entirely.
View full answer

10 Replies

I've checked your code, and the problem is pretty tricky... I can't find any usage of dynamic functions like cookies() or headers. That seems to be strange

Can you try removing all components on the /bot page?
at least I'm not going crazy! I'm going to start digging deeper into debugging today, I'll try removing everything from the bot page, I'm also suspicious that somehow my layout itself might be involved bcause it also does some data fetching (via redis). I'm going to try and disable that bit, and see if it still gets pushed into SSR.
I'm definitely on to something with the data fetching being an issue, some of my logic that interacts with the API I'm using will cache/store some data in redis. I'm wondering if any time I set a key in redis, it's switching the route to SSR for some reason.
Try deleting .next and build again? Sometimes the cache can cause weird behaviours
I'm testing in deployments that are based on docker containers, so every time I deploy the .next folder is getting wiped, don't think it's that
...
this is embarassing
the fetch call I make to the API, I set it to no-cache at some point. it must've been for debugging, but I forgot about it entirely.
Answer
removed that and now it SSG's as expected
it would be nice to have better logging on this, but I really can't blame the library much here lol