Skip to content
Latchkey

Vercel Edge "Dynamic Code Evaluation ... not allowed" in CI

The Edge runtime runs on V8 isolates that disallow eval, new Function, and WebAssembly.compile from a string. When your code or a dependency evaluates code at runtime, the build or request fails.

What this error means

The build or an edge request fails with "Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime", naming the module that uses it.

Vercel
Error: Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile')
not allowed in Edge Runtime
Used by default in node_modules/some-template-engine/index.js

Common causes

A dependency compiles code at runtime

Template engines, schema validators, and serializers sometimes build a function from a string with new Function, which the Edge runtime blocks.

Direct use of eval in edge code

Application code calls eval or new Function directly inside a route or middleware that runs on the Edge runtime.

How to fix it

Move the route off the Edge runtime

If the dependency genuinely needs dynamic evaluation, run that route on the Node runtime where eval is allowed.

app/route.ts
// run on Node instead of Edge
export const runtime = 'nodejs';

Replace the dependency that evaluates code

  1. Read the build error to see which module uses eval or new Function.
  2. Swap it for an edge-compatible alternative that precompiles ahead of time.
  3. Remove any direct eval in your own edge code.

How to prevent it

  • Choose edge-compatible libraries that do not evaluate code at runtime.
  • Keep eval and new Function out of edge routes and middleware.
  • Test edge routes against the Edge runtime locally before deploying.

Frequently asked questions

What causes ""Dynamic Code Evaluation ... not allowed""?
Template engines, schema validators, and serializers sometimes build a function from a string with new Function, which the Edge runtime blocks.
How do I fix "Dynamic Code Evaluation ... not allowed"?
If the dependency genuinely needs dynamic evaluation, run that route on the Node runtime where eval is allowed.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card