Search code examples
servernuxt.jsserverlessserverless-frameworkvercel

Vercel Serverless Function has timed out error


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


Solution

  • 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.