next-translate-routes: Error: spawn E2BIG when running in Docker
Hello everyone,
I’ve been dealing with an interesting and, to me, not very self-explanatory error when running Next.js in Docker using the provided Dockerfile. This whole rabbit hole started after we decided to upgrade from next@13.2.4 to next@13.4.12 (not the latest version due to https://github.com/vercel/next.js/issues/54765).
Basically, what happens is that when running under dev or building and running locally on macOS with a built project, it works fine. However, after building the Dockerfile and running it, it immediately crashes with the following error:
docker run -p 3000:3000 ecommerce-base-storefront
Error: spawn E2BIG
at ChildProcess.spawn (node:internal/child_process:421:11)
at spawn (node:child_process:761:9)
at fork (node:child_process:172:10)
at ChildProcessWorker.initialize (/app/node_modules/next/dist/compiled/jest-worker/index.js:1:10927)
at new ChildProcessWorker (/app/node_modules/next/dist/compiled/jest-worker/index.js:1:10815)
at WorkerPool.createWorker (/app/node_modules/next/dist/compiled/jest-worker/index.js:1:6315)
at new BaseWorkerPool (/app/node_modules/next/dist/compiled/jest-worker/index.js:1:8183)
at new WorkerPool (/app/node_modules/next/dist/compiled/jest-worker/index.js:1:6111)
at new Worker (/app/node_modules/next/dist/compiled/jest-worker/index.js:1:23381)
at createServerHandler (/app/node_modules/next/dist/server/lib/render-server-standalone.js:21:26) {
errno: -7,
code: 'E2BIG',
syscall: 'spawn'
}
I’m not blaming next-translate-routes; however, after several hours, I decided to delete all _routes.json files, and voilà - it started. So I reverted it back and started deleting routes.json one by one (with docker build after each file was deleted). It was fairly time-consuming, but I managed to find a few pages where after deleting _routes.json, projects started working again.
However, there’s nothing that would allow me to relate these _routes.json files together and find some actual issue. They’re all valid JSONs with a valid structure for this library (it worked under 12.2.12) and the pages, of course, build with no issues.
The worst part? I’m unable to reproduce this error in a “cleaner” environment than our main project, so I’m quite stuck in a situation where a few routes cannot be translated. I primarily wanted to ask if somebody else has seen this error as well. 😞
EDIT:
Okay, so it turns out (at least now), that this error is caused by large amount of _routes.json files that are parsed (?). I endedup naming some files as stoproutes.json (so that they don’t get parsed) and it works.
@cvolant don’t you have some inside to this, please? Can I somehow print out number of rewrites, etc. to debug this a bit more?
EDIT2:
Okay, now I’m almost sure, it’s caused by large amount of something. As previously mentioned - i renamed some of my routes to stoproutes.json. I set
translateRoutes: {
routesDataFileName: "stoproutes",
debug: true,
},
and it works. Of course, many pages are not translated, but it works, so there’s no syntactical issue or something.
About this issue
- Original URL
- State: open
- Created 10 months ago
- Comments: 19 (10 by maintainers)
So after some trial and error, I think I’m back on previous version (both
nextandnext-translate-routes). Even though E2BIG seems to be fine, other errors occured which are mentioned in other currently open issues. https://github.com/hozana/next-translate-routes/issues/77