What can I do about Vercel Functions timing out?

Vercel Functions can time out due to various reasons such as long-running tasks or inefficient code. This guide outlines the maximum durations for each Vercel plan and provides troubleshooting steps to address timeout issues.

Maximum function durations

Learn more in the docs on how to configure.

Troubleshooting serverless functions timeouts

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

The function is taking too long to process a request

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 isn't returning a response

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.

You have an infinite loop within your function

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

Upstream errors

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?