Next.js Discord

Discord Forum

Magic Numbers By Next

Answered
Arinji posted this in #help-forum
Open in Discord
https://nextjs-forum.com/post/1223658418028544190
Continuation of this
So i wanted to see how this would behave in a production site where you would obviously fetch from a server action or an api route,

On Build:
ACTION CALLED 2 152
ACTION CALLED 2 144
ACTION CALLED 3 271

When you check on the prod server, starting on /2 you get 144, if you click on the link to Page 2 while still at /2, you get 152. Both of these can be seen on build
starting on /3 you get 147, if you click on the link to Page 3 while still at /3, you get 271.
Where did 147 come from :/

https://codesandbox.io/p/devbox/eloquent-hooks-ccfsss
Answered by Ray
in the html file
View full answer

22 Replies

Answer
I think the job ended before the log so the console.log of the last page didn't get printed to console
try generating one more page and you should see double log for page 3
@Ray I think the job ended before the log so the console.log of the last page didn't get printed to console
yea i see it now, is this really expected behaviour.. since we are making 2 requests to the backend, not 1
just the log didn't get printed to console
if the request is failed the build process will stop
@Ray it is making 2 request
yea i know its making 2... but shldnt it only make 1 request.. whats the reason behind making 2.. one for html and 1 for rsc
cause its a static page, i dont see why an rsc is needed
if you change all <Link /> to <a />, you should see the number from html instead
@Ray if you change all <Link /> to <a />, you should see the number from html instead
so when we make a static page, it gets 2 values where one is incorrect aka the one in the html because of soft navigation.. right?
@Arinji so when we make a static page, it gets 2 values where one is incorrect aka the one in the html because of soft navigation.. right?
how do you define which number is correct, you are using Math.random() lol
@Ray how do you define which number is correct, you are using Math.random() lol
well if you navigate to the page using the Link tag which most do, its also the rsc number
@Arinji well if you navigate to the page using the Link tag which most do, its also the rsc number
if you navigate with Link, if will fetch the data from rsc
so you get the data in rsc file
if you navigate with <a />, you should see the number on html file
hmmmmmmm ok
thnx
if you want the same number on html and rsc file, try using unstable_cache