NextJS Netlify CLI Deno Panic due to "next-dev" edge function

Netlify site name: tom-callahan-blog.netlify.app

I have a NextJS site that I’ve hosted on Netlify for a while (since Next 9 – now on 12.3).

Now I’m trying to use netlify-dev for the first time so that I can try out serverless functions (not edge functions, just regular serverless). I have one Hello World function set up using the sample code in the Netlify docs, called “steam”.

However when I try to run “netlify dev”, it starts the NextJS app, and the Netlify Dev server, I see it setting up all of the environment variables and everything, but as soon as I try to visit the dev site, Deno panics with an error related to the “next-dev” edge function.

The complete terminal output is below. It says it’s because the “next-dev” edge function is trying to run code generated from a string? I assume this next-dev edge function is automatically enabled just because I’m using NextJS on Netlify – I’m not otherwise using any edge functions.

I don’t have any NextJS-related plugins installed anymore (I used to but it looks like that’s all automatic now). I do have one custom plugin to update Algolia, and the Sentry integration, but those are build plugins, I can’t see how they would affect this.

I’ve tried reinstalling netlify CLI, installing it globally, installing it locally, running it with yarn and directly. I tried running it with framework=“#custom” in the Netlify TOML and specifying the command, port, etc… All with no change.

I am running Windows 11 – I haven’t yet tried it on Linux or Mac but could (although I would prefer to not have to do that long-term). This doesn’t seem like a platform issue though if the error is accurate.

yarn run v1.22.11
$ yarn netlify dev
$ "C:\Users\tom\Documents\Design Projects\TCBLOG\frontend\node_modules\.bin\netlify" dev
◈ Netlify Dev ◈
◈ Ignored general context env var: LANG (defined in process)
◈ Ignored site settings env var: ALGOLIA_ADMIN_API_KEY (defined in .env.local file)
◈ Injected .env.local file env var: ALGOLIA_ADMIN_API_KEY
◈ Injected site settings env var: NETLIFY_NEXT_PLUGIN_SKIP
◈ Ignored site settings env var: NEXT_PUBLIC_ALGOLIA_APP_ID (defined in .env.local file)
◈ Injected .env.local file env var: NEXT_PUBLIC_ALGOLIA_APP_ID
◈ Ignored site settings env var: NEXT_PUBLIC_ALGOLIA_INDEX (defined in .env.local file)
◈ Injected .env.local file env var: NEXT_PUBLIC_ALGOLIA_INDEX
◈ Ignored site settings env var: NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_API_KEY (defined in .env.local file)
◈ Injected .env.local file env var: NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_API_KEY
◈ Ignored site settings env var: NEXT_PUBLIC_SNIPCART_API_KEY (defined in .env.local file)
◈ Injected .env.local file env var: NEXT_PUBLIC_SNIPCART_API_KEY
◈ Injected site settings env var: NODE_VERSION
◈ Ignored site settings env var: SANITY_DATASET (defined in .env.local file)
◈ Injected .env.local file env var: SANITY_DATASET
◈ Ignored site settings env var: SANITY_PROJECT_ID (defined in .env.local file)
◈ Injected .env.local file env var: SANITY_PROJECT_ID
◈ Injected site settings env var: SENTRY_AUTH_TOKEN
◈ Injected site settings env var: SENTRY_ORG
◈ Injected site settings env var: SENTRY_PROJECT
◈ Loaded function steam http://localhost:8888/.netlify/functions/steam.
◈ Functions server is listening on 60450
◈ Setting up local development server

────────────────────────────────────────────────────────────────
  Netlify Build
────────────────────────────────────────────────────────────────

❯ Version
  @netlify/build 28.1.7

❯ Flags
  {}

❯ Current directory
  C:\Users\tom\Documents\Design Projects\TCBLOG\frontend

❯ Config file
  C:\Users\tom\Documents\Design Projects\TCBLOG\frontend\netlify.toml       

❯ Context
  dev

❯ Using Next.js Runtime - v4.28.4

❯ Loading plugins
   - @sentry/netlify-build-plugin@1.1.1 from Netlify app
   - /plugins/netlify-plugin-update-algolia@1.2.1 from netlify.toml

────────────────────────────────────────────────────────────────
  1. @netlify/plugin-nextjs (onPreDev event)
────────────────────────────────────────────────────────────────

Patching C:\Users\tom\Documents\Design Projects\TCBLOG\frontend\node_modules\next\dist\server\base-server.js
Done
Patching C:\Users\tom\Documents\Design Projects\TCBLOG\frontend\node_modules\next\dist\server\next-server.js
Done

(@netlify/plugin-nextjs onPreDev completed in 104ms)

────────────────────────────────────────────────────────────────
  2. Run command for local development
────────────────────────────────────────────────────────────────

◈ Starting Netlify Dev with Next.js
$ nextready - started server on 0.0.0.0:3000, url: http://localhost:3000info  - Loaded env from C:\Users\tom\Documents\Design Projects\TCBLOG\frontend\.env.local
✔ Waiting for framework port 3000. This can be configured using the 'targetPort' property in the netlify.toml

(dev.command completed in 1s)

   ┌─────────────────────────────────────────────────┐
   │                                                 │
   │   ◈ Server now ready on http://localhost:8888   │
   │                                                 │
   └─────────────────────────────────────────────────┘

◈ Loaded edge function next-dev
event - compiled client and server successfully in 1729 ms (349 modules)

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: windows x86_64
Version: 1.27.1
Args: ["C:\\Users\\tom\\AppData\\Roaming\\netlify\\Config\\deno-cli\\deno.exe", "run", "--allow-all", "--unstable", "--import-map=data:application/json;base64,eyJpbXBvcnRzIjp7Im5ldGxpZnk6ZWRnZSI6Imh0dHBzOi8vZWRnZS5uZXRsaWZ5LmNvbS92MS9pbmRleC50cyJ9fQ==", "--v8-flags=--disallow-code-generation-from-strings", "--no-config", "--quiet", "C:\\Users\\tom\\AppData\\Local\\Temp\\tmp-21696-kh4ClulIHy9O\\dev.js", "--port", "60482"]

thread 'main' panicked at 'Failed to execute bootstrap script: EvalError: Code generation from strings disallowed for this context
    at new Function (<anonymous>)
    at genAsyncOp (deno:core/01_core.js:169:14)
    at Object.initializeAsyncOps (deno:core/01_core.js:213:19)
    at Object.bootstrapMainRuntime [as mainRuntime] (deno:runtime/js/99_main.js:695:10)
    at [deno:runtime\worker.rs:292:24]:1:11', runtime\worker.rs:293:8       
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Terminate batch job (Y/N)? ^C

 *  The terminal process "C:\WINDOWS\System32\cmd.exe /d /c yarn run netlify-local" terminated with exit code: 1. 

I’m also seeing this. Edge functions were working great for me for a few days until yesterday, where for even something as simple as

export default () => new Response("Hello world");

I started seeing

◈ Reloading edge functions...

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 1.27.1
Args: ["/home/gitpod/.config/netlify/deno-cli/deno", "run", "--allow-all", "--unstable", "--import-map=data:application/json;base64,eyJpbXBvcnRzIjp7Im5ldGxpZnk6ZWRnZSI6Imh0dHBzOi8vZWRnZS5uZXRsaWZ5LmNvbS92MS9pbmRleC50cyJ9fQ==", "--v8-flags=--disallow-code-generation-from-strings", "--no-config", "--quiet", "/tmp/tmp-2304-26UqpnVy5cSm/dev.js", "--port", "42341"]

thread 'main' panicked at 'Failed to execute bootstrap script: EvalError: Code generation from strings disallowed for this context
    at new Function (<anonymous>)
    at genAsyncOp (deno:core/01_core.js:169:14)
    at Object.initializeAsyncOps (deno:core/01_core.js:213:19)
    at Object.bootstrapMainRuntime [as mainRuntime] (deno:runtime/js/99_main.js:695:10)
    at [deno:runtime/worker.rs:292:24]:1:11', runtime/worker.rs:293:8
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
◈ Failed reloading edge function

I tried running the command described here:

Args: ["/home/gitpod/.config/netlify/deno-cli/deno", "run", "--allow-all", "--unstable", "--import-map=data:application/json;base64,eyJpbXBvcnRzIjp7Im5ldGxpZnk6ZWRnZSI6Imh0dHBzOi8vZWRnZS5uZXRsaWZ5LmNvbS92MS9pbmRleC50cyJ9fQ==", "--v8-flags=--disallow-code-generation-from-strings", "--no-config", "--quiet", "/tmp/tmp-2304-26UqpnVy5cSm/dev.js", "--port", "42341"]

And it works if I leave out the --v8-flags=--disallow-code-generation-from-strings option. (this isn’t any kind of solution, just a little experimenting…)

Update: the start of this issue seems to coincide with a new version of Deno (1.27.1) coming out yesterday. I wonder if there’s some way to specify what version I want to use?

Update 2: If I downgrade deno with /home/gitpod/.config/netlify/deno-cli/deno upgrade --version 1.27.0 the error goes away. (still not a solution, just figuring out the cause of the problem)

So after meaning to start exploring functions for many months and just not having time, I apparently picked the exact day this broke to start!

Thanks for the tip, rolling Deno back seems like a perfectly good workaround for my testing purposes. I wonder if this will break when live though, or if this next-dev edge function only runs in dev (I was unable to find any documentation on it).

It does seem to be an issue with the latest release of the Deno CLI.

We’re in the process of rolling out a fix on our side. We’ll update this thread with instructions as soon as there’s an update.

Thanks for bringing this to our attention, and apologies for the inconvenience.

Thanks for the fast response!

We’ve just released version 12.1.0 of the Netlify CLI, which should fix the problem.

You can upgrade by running npm install -g netlify-cli.

If you’re still experiencing the problem after upgrading, please let us know.

@eduardoboucas Yes this works for me! Thanks for fixing this so quickly.

Btw I’d opened a ticket in deno’s github, and they also seem to be working on it on their end, so … is the fix in @12.1.0 a workaround for a Deno bug? Or is it simply accommodating a change on their end?

Confirmed it’s working for me too, thanks for the quick fix!