Next.js Discord

Discord Forum

Please HELP

Unanswered
Oak apple gall wasp posted this in #help-forum
Open in Discord
Oak apple gall waspOP
Link to the code that reproduces this issue
https://github.com/space1worm/serverless-timeout-test

Hey everyone,

Next.js version : 13.5.3
Dir: App Directory

Do you have any ideas about why Vercel is returning a 504 error? I'm on the pro plan, and my serverless function is configured to run for a maximum of 5 minutes. my function for testing purposes needs 1.5m to execute.

In the logs, I can see that the serverless function is returning a 200 status code, and it's executing correctly. However, when I access it through postman, after exactly 1 minute, it returns a 504 error.

Everything works fine locally. What could be the issue?

Here is step by step description how to reproduce:
Go to -> https://test-liart-seven-84.vercel.app/
Click -> 'click to fetch' button

Expected behaviour -> after 1m30s you should see 'Hello World' text
Current behaviour -> Returns 504 Gateway Timeout Error

18 Replies

Oak apple gall waspOP
\
Check if the browser console or the logs are giving you more information
Ohhh btw shouldn't it be "api/hello.ts"
In the function config
Also i dont think you need to specifically set the maxDuration, it should probably automatically set it to 300s if you were on Pro when you created project
Oak apple gall waspOP
No it should be full path to the file, otherwise it throws build error
Also browser console doesn’t give me any info at all
@Clown Ohhh btw shouldn't it be "api/hello.ts"
Oak apple gall waspOP
I can confirmt hat my functions indeed shows that maxDuration is 5m with my configuration
@Oak apple gall wasp By default its 1 minute
I see, i think i read a old vercel blog. They must have changed it since then.
Btw try doing
export const maxDuration = 300

In your route handler as well
Oak apple gall waspOP
Yes I have tried that as well
The thing is I can confirm that maxDuration is 5m and also the function is wxecuted because I see logs which tells me that status is 200 BUt i het in browser gateway timeout which is very odd
I have opened issue on this matter
In vercel/nextjs
There is also discussion about this, some people are experiencing same issue
Leafcutting bee
Having pretty much the same issue here... maxDuration not being honored, and getting a 504.
Have you had any luck here @Oak apple gall wasp ?
Oak apple gall waspOP
I created an issue, and its already fixed