next-on-pages build gives "Internal Server Error" on yarn pages:dev
Hi!
We have a NextJS app and trying to deploy to Cloudflare. On the yarn pages:build step, the following warnings/messages are displayed:
% yarn pages:build
yarn run v1.22.1
$ npx @cloudflare/next-on-pages
⚡️ @cloudflare/next-on-pages CLI v.1.8.2
⚡️ Detected Package Manager: yarn (1.22.1)
⚡️ Preparing project...
⚡️ Project is ready
⚡️ Building project...
▲ Vercel CLI 32.7.2
..
▲ Detected Next.js version: 14.0.4
..
..
[webpack.cache.PackFileCacheStrategy] Serializing big strings (109kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
..
[webpack.cache.PackFileCacheStrategy] Serializing big strings (112kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
▲ ⚠ Compiled with warnings
./node_modules/scheduler/cjs/scheduler.production.min.js
▲ A Node.js API is used (MessageChannel at line: 120) which is not supported in the Edge Runtime.
..
./node_modules/scheduler/cjs/scheduler.production.min.js
▲ A Node.js API is used (setImmediate at line: 51) which is not supported in the Edge Runtime.
The build completes successfully.
The dependency of Scheduler looks like this:
$ npm ls scheduler
<the-app>
└─┬ [email protected]
└── [email protected]
So this is an npm module used by standard react-dom.
Running with yarn pages:dev and launching localhost shows this only message in the browser:
Internal Server Error
And on the command-line this can be seen:
✘ [ERROR] ⨯ TypeError: (w.adapter || b.adapter) is not a function
wrangler:inf] GET / 500 Internal Server Error (178ms)
Not much to go on. There are references to generated files, like:
.../.vercel/output/static/_worker.js/next-on-pages-dist/webpack/86d03c243df5247d6f6729bd979a6117.js:62:138483)
But we assume this is related to the warnings/messages seen while building the application.
Has anyone seen something similar?
We appreciate hint and tips, as there seem to be little information available.
Kind regards,
/Peter
3 Replies
That specific error (
TypeError: (w.adapter || b.adapter) is not a function
) is not one we've seen before. It's possible that the error is coming from something inside the compiled scheduler
dependency, but yeah, with the warnings that Next.js outputted at build time for scheduler
, I'm not sure your application will be able to work correctly tbh.This might be farfetched, but is it possible to debug the NextJS code by which "npx wrangler pages:dev .vercel/output/static --compatibility-date=2023-12-06 --compatibility-flag=nodejs_compat" is executing?
This could possibly help a bit as one would modify the code while trying to spot what goes wrong.
I'm using VSCode (launch.json) and tried some variations, but still unsuccessful.
You can play around with the built code in the _worker.js directory, and mess with the chunk file that the error is thrown in