Edge function crashing on production, works as expected in other environments

site: https://super-selkie-0ef4d9.netlify.app/
dev live: https://super-selkie-0ef4d9-1583f4.netlify.live/

Hey everyone,

I’m running into a strange issue with Edge Functions.

I have a couple of edge functions that do some thing with Stripe and save some things to a supabase db. I’ve been able to get these functions working locally, and on the dev --live environment, but for some reason when I deploy my site to production, the edge functions crash. There is nothing logged to the edge functions console either.

I’ve mostly narrowed it down to one import:

import Stripe from "https://esm.sh/stripe?no-check";

// edge function code

If I deploy an empty edge function without this Stripe sdk esm wrapped import, it works as expected. However, when I use this import (only in production, works fine in local and live dev), the function crashes without any additional logs.

You can see the behavior on the prod site vs dev live as they’re currently deployed.

I also noticed (but don’t know if it’s related), that the environment variables available in production seem to be different than what are available in dev live. For example, the URL var is available in dev live, but not in production.

I’m really puzzled by this, and it doesn’t seem like anyone else has run into this problem. Any ideas?

Thanks in advance!

Hey @tindleaj ,

Would it be possible to share the reproduction steps on the live site so that we may take a closer look?

Also, you mentioned that env vars are different in production versus dev live. I see you have env var defined in the UI > Site settings and was wondering if you have env vars defined elsewhere like in netlify.toml?

Whoops, yeah of course.

  1. Click the ‘I would pay $5 for this’ button
  2. Wait for redirect to crash page ~10 sec

I don’t have any envs defined in netlify.toml, I do have some defined in a local .env

Thanks for the help Audrey!

The envs are the same in both the url and the local env file, same keys and values


Error message: The deployment failed while serving the request.
Netlify internal ID: 01G63X67TEG5M1FFA6ARZJ46QW

hi there @tindleaj - we are still discussing this internally, and will have more information for you soon.

Sure, also I switched to a Next.js / netlify functions stack for now, just to get my MVP working, but I’m happy to redeploy the old edge-function version if it will help you troubleshoot

Hey @tindleaj,

Note that, everything that works in Netlify Functions, is not expected to work in Netlify Edge Functions (and vice-cersa). They’re using two different runtimes (Node vs Deno) so, you can expect stuff accordingly.

Not saying you did not know this, just wanted to make it clear if you didn’t and for other folks who might consider both as direct replacements of each other.

About the library not working, have you checked this:

It appears that Stripe doesn’t have any good ways (yet) to work on Deno. Did you try contacting them about it?

Hey @hrishikesh! Thanks for the follow-up.

Totally understand the difference between regular functions and edge, I’ve been having fun exploring Deno and edge computation and it’s super cool Netlify is adding it.

From that first ticket, it looks like some people have gotten it to work in some deno environments, and Stripe has deno examples like this one. It’s also puzzling because everything works locally, which as I understand is still a deno environment.