#Navigating to api hello results in a

1 messages ยท Page 1 of 1 (latest)

upper tendon
sage pawn
#

I can't reproduce it here but you probably don't want to do return App.getInitialProps(ctx) in your _app

#

it results in an infinite loop because it is calling itself

upper tendon
#

The repro doesn't work locally. It only happens on Vercel

#

The reason for this is because Next.js catches the infinite loop, but in the serverless environment new serverless contexts are created.

sage pawn
#

thanks, I reproduced it locally with your repo

upper tendon
#

Make sure to delete your deployment, it'll rack up requests quick ๐Ÿ˜…

#

oh wait you reproduced locally?

sage pawn
#

it looks like the issue is indeed because of _app

#

yeah

upper tendon
#

Oh cool, I wasn't able to do that

#

next.js always seemed to cut the requests out after 3 fails to render _error

sage pawn
#

so I don't really know why, but next is running App.getInitialProps when the api route is failing

#

and it makes another request to the api route

#

then it fails and runs App.gIP again which results in the infinite loop

upper tendon
#

It's strange. Sorry if I seem a bit argumentative here, i appreciate your help. This just sent an invoice of $1600 over the weekend...

#

Is the best move to contact Vercel to reimburse the charge (an unexpected bug), and then open a bug in Next.js?

#

Perhaps they know some edge case here

sage pawn
#

yeah I think you can create an issue in the repo first and check if the behavior is expected or not

#

I wasn't expecting it because the api routes don't render any layout at all

upper tendon
#

That's what I thought too... which is why I wrote it in the first place ๐Ÿ˜…

#

Welp, ok I'll do that. And when you reproduced it locally did it go infinitely, or just stop at 3? For me it stopped at 3 on local host, but on Vercel it kept going...

For reference I was setting BASE_URL to http://localhost:3000 and doing yarn build && yarn start

sage pawn
#

yeah I did the same thing

#

.env.local file with BASE_URL="http://localhost:3000" and just yarn dev

upper tendon
#

hm ok, well thanks again

sage pawn
#

npm run dev does the same

#

maybe check your node version, I am using 18.15.0

upper tendon
#

And so you're getting infinite requests?

#

im on v18.12.1... hmmm

sage pawn
upper tendon
#

oh wow that is infinite

sage pawn
#

let me know how it goes, I'm curious about this one meow_popcorn

upper tendon
#

oh wow I do get infinite requests now too... I was testing this the other day with a slightly different _app and i only got 3 before it stopped