bloom-filters icon indicating copy to clipboard operation
bloom-filters copied to clipboard

Bug with Next.js Edge runtime on 3.0.4

Open samhenderson511 opened this issue 1 year ago • 10 comments

Bug report

After upgrading to 3.0.4 from 3.0.2, the build fails with the following error:

Failed to compile.

./middleware.ts
Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

The error was caused by importing 'bloom-filters/dist/api.js' in './middleware.ts'.

Import trace for requested module:
  ./middleware.ts

Versions

Next.js: 14.2.13 Node: 22.12

samhenderson511 avatar Dec 10 '24 14:12 samhenderson511

Thank you for the report. Do you have other information about the error? A specific package identified as the root cause of the problem? We updated 2 dependencies since 3.0.2 but also there are a few other sub-dependencies that have been updated in the yarn.lock. Maybe one of them is now using some wasm now.

folkvir avatar Dec 11 '24 14:12 folkvir

@folkvir thanks for checking this out. Do you have any suggestions for testing which package it is? The logs I provided are the only ones I've managed to gather so far

samhenderson511 avatar Dec 14 '24 19:12 samhenderson511

No I don't. I only have the diff between our 2 package versions. We will have to dig into every updated package... https://github.com/Callidon/bloom-filters/compare/v3.0.2...v3.0.4

folkvir avatar Dec 18 '24 10:12 folkvir

I've encountered this as well. I will try to do some testing to find out which package is the cause

Jamiewarb avatar Jan 21 '25 13:01 Jamiewarb

Did you guys ever find a solution ?

fpoirier1 avatar Apr 16 '25 19:04 fpoirier1

No unfortunately still occurring. v3.0.1 was working for me previously

Jamiewarb avatar Apr 17 '25 12:04 Jamiewarb

After some digging, I discovered that this issue occurs when upgrading to NextJS v15, which is why Vercel's example works. I also contacted Vercel support, and their recommended workaround is to use unstable_allowDynamic.

fpoirier1 avatar Apr 17 '25 13:04 fpoirier1

@fpoirier1 could you provide the exact glob or string used with unstable_allowDynamic?

roastlechon avatar Jun 27 '25 19:06 roastlechon

I used https://www.npmjs.com/package/@getkoala/js-bloom instead because it can run in middleware

lukepearson avatar Jul 30 '25 11:07 lukepearson

I have same issue with error below

Image

navata avatar Sep 24 '25 08:09 navata