What can I do about Vercel Functions timing out?

Vercel Functions can time out for various reasons such as long-running tasks or inefficient code. It is important to avoid timeouts as they contribute towards your plan's function duration limits. This guide outlines the maximum durations for each Vercel plan and provides troubleshooting steps to address timeout issues.

Learn more in the docs on how to configure.

If you are seeing an execution timeout error, check the following possible causes:

Check that any API, or database requests you make in your function, are responding within the defined max duration limits applicable to your plan. You can view the runtime logs, or configure your functions to run longer.

The function must return an HTTP response, even if that response is an error. If no response is returned, the function will time out. Please ensure to send an HTTP response to prevent timeouts.

Check that your function is not making an infinite loop at any stage of execution.

If you're connecting to a database or depending on a third-party API before responding, check to make sure there are no errors upstream. Make sure you have all the right environment variables set for talking to third party services successfully.

In the event of an error upstream, it is still good practice to return something informative to the client. If the upstream service hasn't responded to you successfully within a certain time, return a response indicating the error.

Couldn't find the guide you need?