Deployments failing using NextJS and next-on-pages

Hi, We have been deploying our nextjs application for quite some time, and we have been seeing several errors on building that we cannot really diagnose: one is:
20:47:28.559 ▲ Detected Next.js version: 14.0.1
20:47:28.562 ▲ Running "yarn run build"
20:47:29.984 ▲ Attention: Next.js now collects completely anonymous telemetry regarding usage.
20:47:29.985 ▲ This information is used to shape Next.js' roadmap and prioritize features.
20:47:29.985 ▲ You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
20:47:29.985 ▲ https://nextjs.org/telemetry
20:47:30.112 ▲ ▲ Next.js 14.0.1
20:47:30.113 ▲ - Experiments (use at your own risk):
20:47:30.113 ▲ · webpackBuildWorker
20:47:30.113 ▲
20:47:30.114 ▲ Creating an optimized production build ...
20:48:13.428 ▲ Error: Command "yarn run build" exited with 129
20:48:13.467
20:48:13.467 ⚡️ The Vercel build (`npx vercel build`) command failed. For more details see the Vercel logs above.
20:48:13.467 ⚡️ If you need help solving the issue, refer to the Vercel or Next.js documentation or their repositories.
20:48:13.467
20:48:13.502 Failed: Error while executing user command. Exited with error code: 1
20:48:13.511 Failed: build command exited with code: 1
20:48:15.475 Failed: error occurred while running build command
20:47:28.559 ▲ Detected Next.js version: 14.0.1
20:47:28.562 ▲ Running "yarn run build"
20:47:29.984 ▲ Attention: Next.js now collects completely anonymous telemetry regarding usage.
20:47:29.985 ▲ This information is used to shape Next.js' roadmap and prioritize features.
20:47:29.985 ▲ You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
20:47:29.985 ▲ https://nextjs.org/telemetry
20:47:30.112 ▲ ▲ Next.js 14.0.1
20:47:30.113 ▲ - Experiments (use at your own risk):
20:47:30.113 ▲ · webpackBuildWorker
20:47:30.113 ▲
20:47:30.114 ▲ Creating an optimized production build ...
20:48:13.428 ▲ Error: Command "yarn run build" exited with 129
20:48:13.467
20:48:13.467 ⚡️ The Vercel build (`npx vercel build`) command failed. For more details see the Vercel logs above.
20:48:13.467 ⚡️ If you need help solving the issue, refer to the Vercel or Next.js documentation or their repositories.
20:48:13.467
20:48:13.502 Failed: Error while executing user command. Exited with error code: 1
20:48:13.511 Failed: build command exited with code: 1
20:48:15.475 Failed: error occurred while running build command
And other occurrences are out of heap memory limit (and we tried with the NODE_OPTIONS --max-old-space-size of 8192 (even when the console says it only accepts 7GB of mem). We can build in local, with no issues (yes, we have good hardware...). Is there a way to at least output some more information in the logs? Thanks, team!
62 Replies
kev-ac
kev-ac13mo ago
Were there any dependency updates in the last time? There are for example some issues with certain version of the vercel package with next-on-pages. We're currently on ^30.
Eusebio Trigo
Eusebio TrigoOP13mo ago
This specific build contained some dependency updates, but the previous builds were also failing, so.. Anyway, it all started when moving and migrating to the /app folder, and without visibility on the logs we are quite clueless. It is using Vercel CLI 32.5.0, but anyway at the end is running our yarn run build, which runs next build
kev-ac
kev-ac13mo ago
Have you tried building the app locally with next-on-pages? You can run yarn next-on-pages (if your have @ cloudflare/next-on-pages as a dev dependency), it will first run next build and then bundle for pages.
Eusebio Trigo
Eusebio TrigoOP13mo ago
Yes, I did try it. I can also run with npx
kev-ac
kev-ac13mo ago
And this is successful?
Eusebio Trigo
Eusebio TrigoOP13mo ago
That's our build command in the project in Cloudflare. "Works in my local" (tm).
kev-ac
kev-ac13mo ago
mh, I think you're on the latest node LTS (18.x)? Thats what CFs build pipeline uses
Eusebio Trigo
Eusebio TrigoOP13mo ago
yes, node18, (node20 entered LTS 2 weeks ago, but vercel CLI would break the build if you use node20 as they need AWS Lambda (https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) to support node20)
Lambda runtimes - AWS Lambda
Learn about the languages that Lambda supports through runtimes.
kev-ac
kev-ac13mo ago
Interesting, didn't see there is a new LTS version yet. But there is no hurry to update anyways
Eusebio Trigo
Eusebio TrigoOP13mo ago
It depends on AWS and Vercel for that part. Many GitHub actions were upgraded to node20, but that's another topic not relevant now 😉
kev-ac
kev-ac13mo ago
But otherwise I don't really have an idea to debug this. Never encountered such an issue. If it builds fine with next-on-pages locally it worked in CFs build pipeline too
James
James13mo ago
Looks like something is going wrong in Next.js' build process that leads to the Vercel CLI catching an error (129) when it tries to run the build command, although you probably already deduced that much. Maybe using next build --debug would provide more info that might help. Not sure. If it was exceeding the memory limit, I would have expected to see the memory error logged. Maybe segfaulting perhaps, but nothing about that is surfaced :/
Eusebio Trigo
Eusebio TrigoOP13mo ago
I did run with next build --debug and the output is quite short:
08:56:49.710 Executing user command: yarn build
08:56:51.438 ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
08:56:51.451 Attention: Next.js now collects completely anonymous telemetry regarding usage.
08:56:51.452 This information is used to shape Next.js' roadmap and prioritize features.
08:56:51.452 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
08:56:51.452 https://nextjs.org/telemetry
08:56:51.452
08:56:51.585 ▲ Next.js 14.0.1
08:56:51.586 - Experiments (use at your own risk):
08:56:51.586 · webpackBuildWorker
08:56:51.586
08:56:51.586 Creating an optimized production build ...
08:57:37.433 Failed: Error while executing user command. Exited with error code: 129
08:57:37.443 Failed: build command exited with code: 1
08:57:39.487 Failed: error occurred while running build command
08:56:49.710 Executing user command: yarn build
08:56:51.438 ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
08:56:51.451 Attention: Next.js now collects completely anonymous telemetry regarding usage.
08:56:51.452 This information is used to shape Next.js' roadmap and prioritize features.
08:56:51.452 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
08:56:51.452 https://nextjs.org/telemetry
08:56:51.452
08:56:51.585 ▲ Next.js 14.0.1
08:56:51.586 - Experiments (use at your own risk):
08:56:51.586 · webpackBuildWorker
08:56:51.586
08:56:51.586 Creating an optimized production build ...
08:57:37.433 Failed: Error while executing user command. Exited with error code: 129
08:57:37.443 Failed: build command exited with code: 1
08:57:39.487 Failed: error occurred while running build command
(yarn build runs next build --debug)
James
James13mo ago
:/
Eusebio Trigo
Eusebio TrigoOP13mo ago
We have run the same build with the same commitId, same hash, with 10 different branches, and 1 of them failed. Is it possible that the machines that run the build are different on every run? Are there limits on the build size or anything like that? We've been doing more tests, our build works with 13.5.4, but it does not with any following NextJs versions, 13.5.5, 13.5.6, 14.0.1 😦
James
James13mo ago
Likely a newly introduced issue in nextjs from the sounds of things then
Eusebio Trigo
Eusebio TrigoOP13mo ago
Yes... That's what we thought... but we don't dare right now to check 462 commits and 2136 files.
No description
James
James13mo ago
Go through the canary releases first 😛
Eusebio Trigo
Eusebio TrigoOP13mo ago
It seems that someone else has the same issue as we have https://github.com/vercel/next.js/issues/51298 We set the flag to not minimize the build and it is going through... So it really does seem like a memory issue...
GitHub
Edge runtime - JavaScript heap out of memory · Issue #51298 · verce...
Verify canary release I verified that the issue exists in the latest Next.js canary release Provide environment information Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Ver...
James
James13mo ago
Intriguing, thanks for sharing your findings - I didn't expect that to be quite so resource intensive Does you see any difference in final worker size when that is enabled vs disabled?
Eusebio Trigo
Eusebio TrigoOP13mo ago
I will need to get into it and come back later.
Eusebio Trigo
Eusebio TrigoOP13mo ago
If you are asking for:
No description
Eusebio Trigo
Eusebio TrigoOP13mo ago
That's with the flag disabled.
Eusebio Trigo
Eusebio TrigoOP13mo ago
And surprisingly with the flag enabled:
No description
Eusebio Trigo
Eusebio TrigoOP13mo ago
But yeah, same old errors...
17:09:46.586 ▲ Detected Next.js version: 14.0.1
17:09:46.589 ▲ Running "yarn run build"
17:09:48.104 ▲ ⚠ Disabling SWC Minifer will not be an option in the next major version. Please report any issues you may be experiencing to https://github.com/vercel/next.js/issues
17:09:48.230 ▲ ▲ Next.js 14.0.1
17:09:48.230 ▲ - Experiments (use at your own risk):
17:09:48.230 ▲ · webpackBuildWorker
17:09:48.230 ▲ Creating an optimized production build ...
17:14:31.667 Failed: build exceeded memory limit and was terminated
17:09:46.586 ▲ Detected Next.js version: 14.0.1
17:09:46.589 ▲ Running "yarn run build"
17:09:48.104 ▲ ⚠ Disabling SWC Minifer will not be an option in the next major version. Please report any issues you may be experiencing to https://github.com/vercel/next.js/issues
17:09:48.230 ▲ ▲ Next.js 14.0.1
17:09:48.230 ▲ - Experiments (use at your own risk):
17:09:48.230 ▲ · webpackBuildWorker
17:09:48.230 ▲ Creating an optimized production build ...
17:14:31.667 Failed: build exceeded memory limit and was terminated
I thought we tamed it.
James
James13mo ago
The size of the next-on-pages dist folder
Eusebio Trigo
Eusebio TrigoOP13mo ago
Hope is this one. Not minimized.
No description
Eusebio Trigo
Eusebio TrigoOP13mo ago
This one is minimized:
No description
Eusebio Trigo
Eusebio TrigoOP13mo ago
And, yes we have set the NODE_OPTIONS to --max-old-space-size=8192, and the CI warns about that the max size is 7620 Some more background, we have been moving from the pages folder to the app folder in NextJS. Failed: build exceeded memory limit and was terminated 😢
James
James13mo ago
No difference, nice, that means our minifying still takes care of everything regardless of how much swcMinify does Still happening during the Next.js build part?
Eusebio Trigo
Eusebio TrigoOP13mo ago
Yes, still happening after "Creating an optimized production build ..." and before "Compilation successful"
No description
James
James13mo ago
😭
Eusebio Trigo
Eusebio TrigoOP13mo ago
That's also the thing, build in preview succeeds, then hit merge, and the integration tries it in develop (our prod branch), and it fails. If you are going to escalate it somehow I could provide the accountId or anything. Oh, this one is new
Failed: an internal error occurred. If this continues, contact support: https://cfl.re/3WgEyrH
Failed: an internal error occurred. If this continues, contact support: https://cfl.re/3WgEyrH
More tomorrow...
Erisa
Erisa13mo ago
Hi there ?pages-deployment-id
Flare
Flare13mo ago
The Pages deployment ID is a unique build identifier. It's the UUID in the browser bar (for example, a URL would be dash.cloudflare.com/ACCOUNT_ID/pages/view/PROJECT/DEPLOYMENT_ID where the deployment ID looks something like a398d794-7322-4c97-96d9-40b5140a8d9b). This ID can help troubleshoot some issues with Pages builds so if you have a failing build make sure you grab that ID for the Pages team to use.
Erisa
Erisa13mo ago
Could you share a deployment ID?
Eusebio Trigo
Eusebio TrigoOP13mo ago
Sure, 7feed5cc-d39a-4bf3-af44-99393feaa616 This one failed with an internal error: 69ec6c4f-28c2-4171-936b-7bd263c1afda
Erisa
Erisa13mo ago
This one was OOM killed for running out of memory Checking the other
Eusebio Trigo
Eusebio TrigoOP13mo ago
Yes, we are trying to know why it goes over the limit when compiling the NextJS application and its app folder... Thanks for checking those builds!
Erisa
Erisa13mo ago
This seems to have genuinely been an internal error but feels transient, does it work or give another error on a retry? May also have been an OOM that wasn't caught
Eusebio Trigo
Eusebio TrigoOP13mo ago
I did retry the build. Yes, all my last builds about it are raising OOM.
Erisa
Erisa13mo ago
Alright
Eusebio Trigo
Eusebio TrigoOP13mo ago
This one went through! 83013e77-ebd5-435f-958f-716cdc4ae35f
Eusebio Trigo
Eusebio TrigoOP13mo ago
No description
Eusebio Trigo
Eusebio TrigoOP13mo ago
I'll keep an eye on the following builds we do (well, the integration with GitHub and our CI takes care of it 😉 ). This has been an ongoing problem for us during the last 2 weeks 😦 I'll continue tomorrow with more builds
Eusebio Trigo
Eusebio TrigoOP13mo ago
Morning (here)! There are other people who did some memory analysis and commented on the thread in GitHub about it https://github.com/vercel/next.js/issues/54708#issuecomment-1771802059
GitHub
Next.js development high memory usage · Issue #54708 · vercel/next....
Before posting a comment on this issue please read this entire post. Previous work The past few weeks we've been investigating / optimizing various memory usage issues. Specifically geared towa...
Eusebio Trigo
Eusebio TrigoOP13mo ago
Sharing it so you may be aware that this can happen to other teams. We are back at this again, moved 3 pages from the pages to the app folder, and started the memory issue because of compiling for the edge.
James
James13mo ago
😭 😭
Eusebio Trigo
Eusebio TrigoOP13mo ago
No progress today. All of them OOM.
No description
Eusebio Trigo
Eusebio TrigoOP12mo ago
I saw that there is a new version of next-on-pages that was solving some issues to make it compatible with 14.0.2. I tried a deployment, it went well, but tried again, and it failed, again. For the same reasons.
James
James12mo ago
Yeah that fix won't improve your issue sadly, was just to patch a bug that they shipped in nextjs that broke rendering on Workers
Eusebio Trigo
Eusebio TrigoOP12mo ago
I made it!
No description
Eusebio Trigo
Eusebio TrigoOP12mo ago
Full page with build errors! I don't know what to check or do. Will see if 14.0.3 fixes something from Mon. Otherwise will try publishing the pages from GitHub Actions. We will lose the preview then... which is not good. Uhm, it is possible to publish to preview...
James
James12mo ago
You can publish to preview still. You can tell wrangler which branch to publish as. Not sure if the pages-action does that automatically or not
Erisa
Erisa12mo ago
wrangler does it automatically based on current checkout which pages-action will also end up doing since it uses wrangler
Eusebio Trigo
Eusebio TrigoOP12mo ago
We were deploying to our "demo" and "prod" environments using GitHub Actions, so it was a matter of copying and pasting for us. When setting the branch, it always displays ¨HEAD¨ in Cloudflare´s deployment list, if the name of the branch I tell it in the parameter ¨branch¨ of cloudflare/pages-action is different from ´develop´.
Eusebio Trigo
Eusebio TrigoOP12mo ago
Like
No description
Eusebio Trigo
Eusebio TrigoOP12mo ago
We delete the branches after we merge the PRs, I'll have a look next time we just push a PR.
Erisa
Erisa12mo ago
I dont think it should be showing HEAD, are you able to share more than just that crop or a deployment ID?
Eusebio Trigo
Eusebio TrigoOP12mo ago
No description
Eusebio Trigo
Eusebio TrigoOP12mo ago
DeploymentId a5d11c9e-fce3-4749-9d33-562e82acfdbb I'm thinking that as I suspended the access to the Cloudflare App in GitHub, then you don't have access to our account anymore. I didn't want to disconnect the whole apps, but I may do it soon.
CharlieS
CharlieS12mo ago
next 14
Want results from more Discord servers?
Add your server