vercel@39.1.2 のアップデートによりデプロイに失敗するようになってしまいました...
@cloudflare/next-on-pages 1.13.7 以上にアップデートすることにより、この問題は解決しました
動作確認環境
Next.js 15.0.3 (App router)
vercel 39.1.2 → 39.1.1
@cloudflare/next-on-pages 1.13.6
先日、このホームページを更新しようとしたところ、以下のようなエラーでデプロイに失敗しました
async_hooks が見つからないというエラーです
Node.js v22.11.0Error: R] Could not resolve "async_hooks"<stdin>:118:680:118 │ ...:()=>N});var R=A(require("async_hooks")),S="@next/request-cont...╵ ~~~~~~~~~~~~~The package "async_hooks" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.Error: R] Could not resolve "async_hooks"<stdin>:118:680:118 │ ...:()=>N});var R=A(require("async_hooks")),S="@next/request-cont...╵ ~~~~~~~~~~~~~The package "async_hooks" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.Error: Process completed with exit code 1.
根本の原因としては vercel が 39.1.2 にアップグレードしたことに依るもののようです
この問題はすでに GitHub の Issue でも議論されており、現在ではすでにパッチも提供されています
以下のようにして解決できます
package.json を書き換えて @cloudflare/next-on-pages を 1.13.6 以上にアップグレードする
あるいは、npx や yarn dlx 等の実行時にバージョンを指定する
npx @cloudflare/next-on-pages@1.13.6 Cloudflare のダッシュボードを開き Runtime の Compability date (互換性の日付) を 2024-11-11 以降に設定する

...なんですけど、デプロイはできるようになったのですが route.ts で構成される API が動作しなくなりました
500 Internal Server Error と応答していて、ダッシュボードから下のようなログが取れました
{"logs": [{"message": ["TypeError: Illegal invocation: function called with incorrect `this` reference. See https://developers.cloudflare.com/workers/observability/errors/#illegal-invocation-errors for details."],"level": "error",}]}
Edge Runtime を使ったページは閲覧できるので、Edge の機能が全てが使えないわけではなさそうですね
ただ API も使えないと困るので、暫定的な対応として vercel を 39.1.1 にダウングレードすることにしました...
おわりに
再現性がどの程度かわかっていないので報告していないですが、時間ができたら Issue を立てようかなと思います 🐶
(2024年12月5日 追記)
すでに Issue が立てられていましたが Vercel の問題として指摘していますね
やはり、現状はダウングレードするしかなさそうです...
(2024年12月14日 追記)
@cloudflare/next-on-pages 1.13.7 により全ての問題が解消されたようです
vercel 39.2.2 で動作確認したところ、私の環境では問題なさそうでした