framesjs / frames.js

The fastest way to make Frames
https://framesjs.org
MIT License
344 stars 98 forks source link

@frames.js/render Build error occurred Error: Failed to collect page data for #393

Open stephancill opened 4 months ago

stephancill commented 4 months ago

Error

% yarn next build
yarn run v1.22.19
$ /Users/stephan/environments/mod/frames-render-demo/node_modules/.bin/next build
  ▲ Next.js 14.2.3

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
   Collecting page data ../Users/stephan/environments/mod/frames-render-demo/.next/server/app/page.js:32
 */e.parse=o,e.serialize=s;var i=decodeURIComponent,n=encodeURIComponent,r=/; */,t=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function o(e,a){if("string"!=typeof e)throw TypeError("argument str must be a string");for(var n={},t=a||{},o=e.split(r),s=t.decode||i,u=0;u
...
__create(__getProtoOf(e)):{},__copyProps(!a&&e&&e.__esModule?i:__defProp(i,"default",{value:e,enumerable:!0}),e)),__publicField=(e,a,i)=>(__defNormalProp(e,"symbol"!=typeof a?a+"":a,i),i),init_esm_shims=__esm({"../../node_modules/tsup/assets/esm_shims.js"(){}}),require_long=__commonJS({"../../node_modules/long/src/long.js"(e,a){init_esm_shims(),a.exp

> Build error occurred
Error: Failed to collect page data for /
    at /Users/stephan/environments/mod/frames-render-demo/node_modules/next/dist/build/utils.js:1268:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'Error'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Steps to reproduce

  1. Create a new next.js app using create-next-app
  2. follow usage guide at https://framesjs.org/guides/apps/display-frames
  3. yarn build
  4. error

Workaround

Fix the error by disabling prebuilding

yarn next build --experimental-build-mode compile
michalkvasnicak commented 3 months ago

This is an upstream issue, probably in next.js. It doesn't work in next@14.2.x but downgrading to 14.1.4 fixes that.

I was able to trace it to @farcaster/core dependency that breaks the next.js@14.2.x production build, but wasn't able to find what exactly causes the build to fail.

chuckstock commented 2 months ago

just confirmed this is still an issue for nextjs builds, but the work around for the next build still fixes it.

porenes commented 1 month ago

Could it be related to https://github.com/farcasterxyz/hub-monorepo/issues/2031#issuecomment-2154855700 ?

pdelfan commented 6 days ago

I'm running into the same issue. The workaround doesn't work for me. It builds successfully but running it leads to the following error:

Identifier 'a56' has already been declared

I'm using useAnonymousIdentity if that makes a difference.

davidfurlong commented 5 days ago

Identifier 'a56' has already been declared

have you tried setting swcMinify: false, in next.config.js @pdelfan ?

bmann commented 5 days ago

@davidfurlong FYI @pdelfan is doing experiments with Bluesky.

pdelfan commented 4 days ago

Identifier 'a56' has already been declared

have you tried setting swcMinify: false, in next.config.js @pdelfan ?

Thanks! I downgraded to 14.1.4 and tried it, but the it leads to another error:

./node_modules/cheerio/node_modules/undici/lib/web/fetch/util.js
Module parse failed: Unexpected token (860:57)
File was processed with these loaders:
 * ./node_modules/next/dist/build/webpack/loaders/next-flight-loader/index.js
 * ./node_modules/next/dist/build/webpack/loaders/next-swc-loader.js
You may need an additional loader to handle the result of these loaders.
|       // 5. If object is not a default iterator object for interface,
|       //    then throw a TypeError.
>       if (typeof this !== 'object' || this === null || !(#target in this)) {
|         throw new TypeError(
|           `'next' called on an object that does not implement interface ${name} Iterator.`

Import trace for requested module:
./node_modules/cheerio/node_modules/undici/lib/web/fetch/util.js
./node_modules/cheerio/node_modules/undici/lib/web/fetch/headers.js
./node_modules/cheerio/node_modules/undici/index.js
./node_modules/cheerio/dist/esm/index.js
./node_modules/frames.js/dist/chunk-N6D3CXG6.js
./node_modules/frames.js/dist/index.js
./node_modules/@frames.js/render/dist/chunk-OGFFZ33X.js
./node_modules/@frames.js/render/dist/next/index.js
./src/app/api/frames/route.tsx

It does work in dev mode:

https://github.com/user-attachments/assets/4ce090dc-653f-4149-99b3-07acce96deb9