Skip to content

Edge Functions Limitations

Learn about the limitations of using Edge Functions with Vercel.
Warning: Edge Functions are currently in Beta . The API might change as we look to continually make improvements.

Edge Functions are neither Node.js nor Browser applications. We instead offer a subset of browser APIs. There are some restrictions to writing Edge Functions. Restrictions are documented in the Edge Functions API guide, in summary:

  • Use ES modules.
  • Libraries using Node.js APIs can't be used in Edge Functions. See available APIs.
  • Dynamic code execution (such as eval) is not allowed (see the next section for more details).

Dynamic code execution is not available in Edge Functions for security reasons. For example, the following APIs cannot be used:

  • eval()
  • new Function()
  • WebAssembly.instantiate() with a buffer parameter

Most importantly, you need to make sure libraries used in your Edge Functions don't rely on dynamic code execution because it leads to a runtime error.

The maximum duration for Edge Function execution is 5 seconds.

This means that you should return a response as soon as possible, and continue with any asynchronous workloads in the background, after returning the response.

An Edge Function can only use up to 128MiB. If it exceeds this limit, the execution will be aborted and we will return a 502 error.

The maximum size for an Edge Function is 1 MiB after compression, including your JavaScript code, imported libraries, and all files bundled in the function.

If you reach the limit, make sure the code you are importing in your function is used and is not too heavy. You can use a package size checker tool like bundle to check the size of a package and search for a smaller alternative.

Name
Limit
Maximum URL length
14KiB
Maximum request body length
4 MiB
Maximum number of request headers
64
Maximum request headers length
16KiB

The maximum number of requests from fetch API is 950.

Date.now() only advances after I/O operations (e.g. fetch).

for (let i = 0; i < 1000; i++) {
  console.log(Date.now()); // Prints the same value 1000 times.
}

await fetch('https://vercel.com');
console.log(Date.now()); // Prints another value.