Skip to content
Latchkey

Netlify Edge "Failed to load edge function" in CI

Netlify Edge Functions run on Deno. During the build Netlify bundles each function with the edge bundler; if a function throws at module load, imports something unavailable, or has a syntax error, the build reports it failed to load.

What this error means

The Netlify build fails with "Failed to load edge function <name>" or "Bundling of edge function failed", often with a Deno error or a stack trace from the function module.

Netlify
Bundling edge functions...
Failed to load edge function "geolocate":
  error: Uncaught SyntaxError: The requested module './util.ts' does not provide
  an export named 'lookup'

Common causes

A bad import or missing export in the function

The function imports a name that the target module does not export, or references a file path that does not exist, so Deno fails to evaluate the module.

Code that runs at module top level and throws

Initialization at the top of the function file throws during bundling, so the function never loads.

How to fix it

Run the edge bundler locally

  1. Reproduce with netlify build or netlify dev to see the same load error.
  2. Fix the missing export, wrong path, or top-level throw it reports.
  3. Confirm the function exports a default handler.
netlify/edge-functions/geolocate.ts
export default async (request, context) => {
  return new Response('ok');
};

Keep top-level code side-effect free

Move initialization into the handler so a slow or failing setup does not break module load.

How to prevent it

  • Run netlify build locally before pushing edge function changes.
  • Export a default handler and keep imports correct.
  • Avoid throwing work at the top level of an edge function.

Frequently asked questions

What causes ""Failed to load edge function""?
The function imports a name that the target module does not export, or references a file path that does not exist, so Deno fails to evaluate the module.
How do I fix "Failed to load edge function"?
Run the edge bundler locally

Related guides

References

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