JSONHTTPError when deploying Next.js app inside Nx workspace
Describe the bug
I'm trying to deploy a next.js app that's inside a Nx workspace using netlify-cli. I have configured the build settings as show below in the netlify.toml file and in the netlify UI. I have logged in using the cli and I'm setting the site ID as an environment variable in my terminal.
The app builds without problem including the @netlify/plugin-nextjs output, the issue begins at the upload stage. After 20 minutes (at least) it just errors out with this message:
{
"name": "JSONHTTPError",
"status": 500,
"json": {
"status": 500,
"error": "Internal Server Error"
}
}
I have tried running the deploy command as:
npx netlify deploy --prod --build
as well as:
npx netlify build
npx netlify deploy --prod
with no luck.
I have also tried doing the same with a clean nx workspace with a next app, here's the repo. The error is the same and it takes the same amount of time
Here's the full log with the DEBUG=* env variable in my original project: error.txt
Steps to reproduce
- git clone https://github.com/AlanAcDz/nx-next-test.git
- npm install (it includes netlify-cli as a devDependency)
- npx netlify login
- set site ID as environment variable
- npx netlify deploy --build --prod
- *go get a coffee and a snack cause it takes a while
- the cli errors out
Configuration
[build] command = "nx build next-test" publish = "dist/apps/next-test/.next"
[[plugins]] package = "@netlify/plugin-nextjs"
Environment
System:
OS: Windows 10 10.0.22000
CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
Memory: 4.76 GB / 15.36 GB
Binaries:
Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
npm: 8.9.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
netlify-cli: ^10.2.0
Forgot to mention, this issue is found only using the netlify-cli. If I activate github builds in the UI there is no problem whatsoever using the same configuration, the app builds and deploys just fine
Seeing the same thing, started happening this morning with a build triggered by content changes in the CMS.
2022-05-13T09:15:49.0557514Z Deploying to main site URL...
2022-05-13T09:15:49.6208989Z - Hashing files...
2022-05-13T09:15:49.6238898Z - Looking for a functions cache...
2022-05-13T09:15:49.6259193Z √ Deploying functions from cache (use --skip-functions-cache to override)
2022-05-13T09:15:50.5900168Z √ Finished hashing 1249 files and 3 functions
2022-05-13T09:15:50.5900729Z - CDN diffing files...
2022-05-13T09:15:52.2079659Z √ CDN requesting 497 files and 2 functions
2022-05-13T09:15:52.2087417Z - Uploading 501 files
2022-05-13T09:38:43.2252409Z » Warning: JSONHTTPError: 500
2022-05-13T09:38:43.2253876Z » Warning:
2022-05-13T09:38:43.2255033Z {
2022-05-13T09:38:43.2256173Z "name": "JSONHTTPError",
2022-05-13T09:38:43.2256582Z "status": 500,
2022-05-13T09:38:43.2259076Z "json": {
2022-05-13T09:38:43.2259387Z "status": 500,
2022-05-13T09:38:43.2260896Z "error": "Internal Server Error"
2022-05-13T09:38:43.2261306Z }
2022-05-13T09:38:43.2261547Z }
2022-05-13T09:38:43.2262133Z
2022-05-13T09:38:53.7609169Z » JSONHTTPError: Internal Server Error
2022-05-13T09:38:53.7990365Z error Command failed with exit code 1.
Update: so I installed latest version of netlify-cli (10.3.3), still does not work but now the error is completely different. I'm attaching the new error, although it seems not to be the full error, my terminal did not keep the whole thing
Update 2: with version 10.4.0 of netlify-cli, it outputs the same error as it was before:
{
"name": "JSONHTTPError",
"status": 500,
"json": {
"status": 500,
"error": "Internal Server Error"
}
}
It's been a whole month since I first opened this issue and yet there has been no acknowledgement of it.
@rshackleton are you still seeing this error too?
We ended up changing the site to not build as many pages statically to try and workaround the issue, so not we're not but we probably would be if we changed it back.
Update 3: I have tried upgrading to the latest version 10.5.0 and downgrading to version 9.16.7, neither works. This makes me think that the issue might not be within netlify-cli itself and instead be the connection bewteen netlify-cli and netlify servers in this specific situation (nx workspace with nextjs app)
I may continue to post updates every now and then about this issue, at least until it's acknowleged. If someone else encounters this I advice you to use netlify's UI to deploy your nx apps, that one works fine
This only happens if you have large dependencies and static pages generated. Try limiting it, if you can't, there's no really good option but only publish it using github or other pipeline.
Interesting, I am in fact generating static pages but I don't think 17 of them would cause the issue and none of them is more than 5kb. Either way it seems really strange that only netlify-cli has this issue
We've changed our handling of monorepos in v16+ . Is this issue still occurring?