Debugging Edge Functions error

Hello,

I’m excited to try out the new Netlify Edge Functions beta, but I’m running into an error without any actionable information so I could use some help to figure out next steps.

An unhandled error in the function code triggered the following message:

The deployment failed while serving the request.
Connection details
Netlify internal ID: 01G16QHZAKGBA82DBPFR503FRZ

You can see the error here: https://6261a5485d2ff70009f76bbc--precious-figolla-e4e921.netlify.app/my/netlify/edge/function.

In the edge function logs I see this:

11:45:49 AM: ReferenceError: Z_VERSION_ERROR is not defined
    at netlify:bundle-combined:47037:22

The build succeeded, so it seems like the deno bundle was successful, so I’m not sure what I should be looking at to try to fix the error.

For context, my edge_handler config in my netlify.toml looks like this:

[[edge_functions]]
  path = "/my/netlify/edge/function"
  function = "server-render"

(Here’s the full context in the GitHub repo).

I’m testing out an adapter for a frontend framework I maintain, elm-pages.

There are two areas I can think of to look for errors, but since it seems like the deno bundle step is succeeding I’m not sure if that means the problem is elsewhere.

  1. I’m using a CommonJS-style require. I need to do this to pull in the compiled Elm code. I had to use version 0.130.0 of deno std instead of the latest (0.136.0) to avoid an error that came up from unstable API references, so this is what that code looks like (full code snippet on GitHub):
import { createRequire } from "https://deno.land/std@0.130.0/node/module.ts";
const require = createRequire(import.meta.url);
  1. I am require’ing some modules using relative paths. Like require("../../../../../generator/src/render");. So I wonder if the paths could be different in the build environment (or the deployed environment). Maybe the Deno bundle step succeeds because the bundling only happens for ESM imports, and the CommonJS require happens dynamically. Could this be the source of the error? And if so, is it possible for me to reference some of the source code from the git repo within my edge functions? Is there a way to make sure those files are included without copying them, or is copying them the recommended practice?

I hope that’s enough context to be an actionable question. Thanks for any insights on this!

I tried deploying the hello world example from the docs, and it seems like I’m getting the same error there as well:

ReferenceError: Z_VERSION_ERROR is not defined
    at netlify:bundle-combined:47039:22

You can see it running here:

https://6261e1adab8c030008f7d321--precious-figolla-e4e921.netlify.app/test/hello

This project is using a base path. Is it possible that there is an issue related to that?

Hey there, @dillonkearns :wave:

Thanks for reaching out about this and for sharing your logs! I have looped in a member of my team who has worked more closely with edge functions. Hang tight!

1 Like

Hey @dillonkearns,

Does the error persist when deploying that function on a separate site?

I tried deploying the hello example (from the netlify edge function examples) with a base directory configured, and it works fine:

https://main--celebrated-muffin-cc23b0.netlify.app/hello

I notice that the error points to the netlify:bundle-combined. Could it be an issue with the other edge functions, or would each individual edge function be bundled separately?

Also, for reference, in the netlify CLI both of these edge functions run as expected with no errors (both the hello.js example and the more complex server-rendering example I’m trying to build).

Hey @dillonkearns,

Sorry for the delay. Could you please clarify the following?

I’m not sure what you mean by:

vs

which base path are you talking about and how is that relating to the error?

The small example I created from the fork of edge-functions-examples above was just to narrow down whether using the hello world example with the only change being using a base path would cause an error. It didn’t have any errors, so I was just trying to narrow down one possible cause of the issue.

Hope that helps, let me know if I can clarify anything else.

Thank you for the information, we saw this happening for you as well when we followed the links you shared. I am not sure if it has to do with your base path, but we have raised this with the team that built edge functions. We will follow up here when we know more!

1 Like