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. Currently, our runtime offers a subset of browser APIs and some Node.js APIs, and we plan to implement more in the future.
There are some restrictions to writing Edge Functions, which are documented in the Edge Runtime docs.
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:
API | Description |
---|---|
Evaluates JavaScript code represented as a string | |
Creates a new function with the code provided as an argument | |
Compiles and instantiates a WebAssembly module from a buffer source |
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 Edge Function must begin sending a response within 25 seconds. You may continue streaming a response beyond that time.
Learn more about streaming responses from Edge Functions.
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 gzip 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.
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.
To avoid CPU timing attacks, like Spectre, date and time functionality is not generally available. In particular, the time returned from Date.now()
only advances after I/O operations, like fetch
. For example:
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.
Was this helpful?