Skip to content

Edge Functions Limitations

Learn about the limitations and restrictions of using Edge Functions with Vercel with this reference.

Edge Functions are neither Node.js nor Browser applications, which means they don't have access to all Browser and Node.js APIs. However, we currently offer a subset of browser APIs and some Node.js APIs, and plan to implement more in the future.

There are some restrictions to writing Edge Functions, which are documented in the Edge Functions API guide.

In summary:

  • Use ES modules
  • Most libraries which use Node.js APIs as dependencies can't be used in Edge Functions yet, but we're adding support for more Node.js APIs over time. See available APIs for a full list
  • 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 30 seconds.

The Edge Function must begin sending a response within 30 seconds. You may continue streaming a response beyond that time.

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

Plan
Limit (after compression)
Hobby
1 MB
Pro
2 MB
Enterprise
4 MB

The maximum size for an Edge Function includes your JavaScript code, imported libraries and files (such as fonts), 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.

While Vercel allows Environment Variables up to a total of 64 KB in size, Edge Functions are limited to 5 KB per Environment Variable.

Environment Variables can be accessed through the process.env object. Since JavaScript objects have methods to allow some operations on them, there are limitations on the names of Environment Variables to avoid having ambiguous code.

The following names will be ignored as Environment Variables to avoid overriding the process.env object prototype:

  • constructor
  • __defineGetter__
  • __defineSetter__
  • hasOwnProperty
  • __lookupGetter__
  • __lookupSetter__
  • isPrototypeOf
  • propertyIsEnumerable
  • toString
  • valueOf
  • __proto__
  • toLocaleString

Therefore, your code will always be able to use them with their expected behavior:

// returns `true`, if `process.env.MY_VALUE` is used anywhere & defined in the Vercel dashboard
process.env.hasOwnProperty('MY_VALUE');
Name
Limit
Maximum URL length
14 KB
Maximum request body length
4 MB
Maximum number of request headers
64
Maximum request headers length
16 KB

The maximum number of requests from fetch API is 950.

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

index.js
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.