23

I have a Nuxt.js server side website deployed on Vercel. I've noticed that, on some occasions, I get a 504: GATEWAY_TIMEOUT error, with the code FUNCTION_INVOCATION_TIMEOUT and the message "This Serverless Function has timed out".

Why am I seeing this error?

Serverless function has timed out

2
  • Ran in to this issue today and I found that hosting a database in Australia and trying to use graphQL with a few hits to the database per request definitely causes the issue every time. Commented Mar 5, 2022 at 11:19
  • 1
    @DejanVasic I think I discovered the issue. I found that since I was using heroku on the free tier. The server sleeps after some due to inactivity, that is mostly when the issue arises. I also noticed in another project where the server is always active that I do not have that issue there. Commented Mar 6, 2022 at 12:16

4 Answers 4

32

Vercel imposes some limits when using their platform. This includes a serverless function execution timeout, which is basically the amount of time that a serverless function is allowed to process an HTTP request before it must respond.

If you need a longer execution timeout, you can try using Edge functions. They have to return a response in 30 seconds but can stream indefinitely.

Recently, they have silently reduced the serverless function execution timeout from 10s for the hobby plan, 60s for the pro plan and 1000s for the enterprise plan to, respectively, 5s, 15s and 30s. This might be the reason why you're experiencing this error now.

I really didn't like the fact that they lowered these limits without warning their users (I wasn't warned, at least) and giving them time to adjust.

Sign up to request clarification or add additional context in comments.

5 Comments

makes total sense, since my API is on Heroku free plan, and it times out once in a while
I won't be surprised, they did it before (back when the company name was Zeit) when they deprecated API v1 without consulting their customers or giving them much time to upgrade their websites. Migration wasn't even easy and they had to drop using Docker. Many developers complained about having to migrate all of their websites on the planform to keep using their service.
Seems like Netlify is the way to go
useful link to deploy next 13 to AWS: reddit.com/r/nextjs/comments/yps1zh/comment/ivkvqpw/…
Those are the default timeouts now, but if are in the pro plan, you can extend the limit in your functions up to 5 minutes for execution time: vercel.com/changelog/…
8

As of 7 September 2022, the Hobby plan on Vercel supports Serverless Function Execution Timeout for 10 seconds. Pro for 60 seconds. Enterprise for 900 seconds. enter image description here

Here is a link to their pricing plans: https://vercel.com/pricing

3 Comments

Do you know of any FREE providers with a longer execution timeout?
Definitely depends on the framework, i think you can still use vercel but with slightly different set up
The last time i failed with vercel: ML model was too large. Here is freecodecamp article on alternatives freecodecamp.org/news/…
4

Check if setting region using vercel.json will help.

Deployment regions: https://vercel.com/docs/concepts/edge-network/regions

1 Comment

closest I could get to Iowa (the database location) was Cleveland (the Vercel region). Still no dice.
4

For anyone landing here from Google, you can now configure Vercel Functions to run for up to 5 minutes.

https://vercel.com/changelog/serverless-functions-can-now-run-up-to-5-minutes

4 Comments

Heyy Lee is this still true?
Yes! This is still accurate.
I switched from netlify to vercel for this.
I’ve spent a few days now getting a nextjs 14 app using NextAuth v5 with google as an OAuth provider, a jwt strategy, persisting to mongodb working and when I deploy to production I cannot sign in on the hobby plan because it times out every time. This is really disappointing. I would be happy to pay maybe $5 a month to extend this one call but Vercel has made it impossible to run what I would consider a minimal app on the hobby plan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.