frames.js icon indicating copy to clipboard operation
frames.js copied to clipboard

Next.js App Router Error: Dynamic Code Evaluation not allowed in Edge Runtime

Open grantoesterling opened this issue 1 year ago • 3 comments

Running into the Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime error when adding the frame creation to generateMetadata in my Next14 app, as laid out in the docs here: https://framesjs.org/reference/core/next

Am I missing something or is this broken? :)

grantoesterling avatar Jul 19 '24 17:07 grantoesterling

@grantoesterling could you provide minimum reproducible code? We don't use WebAssembly directly so it must be an issue with some package. Since you provided only the error message it's hard to know where that happened.

michalkvasnicak avatar Jul 22 '24 06:07 michalkvasnicak

It sounds like some other part of your code isn't compatible with Vercel's edge runtime. You may want to try configuring it to use the Node.js runtime https://vercel.com/docs/functions/configuring-functions/runtime#node.js

davidfurlong avatar Jul 22 '24 09:07 davidfurlong

@michalkvasnicak sorry I should have included this, seems to be failing because of one of the framejs imports

../../node_modules/@protobufjs/inquire/index.js
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

Import trace for requested module:
../../node_modules/@protobufjs/inquire/index.js
../../node_modules/protobufjs/src/util/minimal.js
../../node_modules/protobufjs/src/index-minimal.js
../../node_modules/protobufjs/minimal.js
../../node_modules/frames.js/dist/chunk-MI43JRER.js
../../node_modules/frames.js/dist/next/index.js
./src/app/collections/[idOrSlug]/page.tsx


> Build failed because of webpack errors

@davidfurlong reasonably certain it isn't another part of my code as the error disappears when I comment the frame.js await fetchMetadata piece out of the generateMetadata section of that page. Tried adding that nodejs runtime to the framejs route but still getting the same error

Worth noting this is on Next 14.1.3 and frames.js version 0.17.4

grantoesterling avatar Jul 22 '24 16:07 grantoesterling