Magic Numbers By Next
Answered
Arinji posted this in #help-forum
ArinjiOP
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
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
22 Replies
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
ArinjiOP
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
ArinjiOP
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
@Arinji cause its a static page, i dont see why an rsc is needed
for soft navigation
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
ArinjiOP
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
ArinjiOP
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
ArinjiOP
hmmmmmmm ok
thnx
if you want the same number on html and rsc file, try using
unstable_cache@Ray if you want the same number on html and rsc file, try using `unstable_cache`
ArinjiOP
works beautifully, thanks :D