jest-worker breaks building the project with "write EPIPE" error on macOS
See original GitHub issueWhat version of Next.js are you using?
11.0.1
What version of Node.js are you using?
16.4.2
What browser are you using?
Firefox
What operating system are you using?
macOs Big Sur 11.4 (MacBook Pro 15" 2017)
How are you deploying your application?
next build
Describe the Bug
I’ve decided to move my project on to next@11.0.1, using macOS for development. When i try building it, i get the following lines:
info - Loaded env from /Users/brrrrrr/.env
(node:99496) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
info - Checking validity of types
info - Creating an optimized production build .node:events:371
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at ChildProcess.target._send (node:internal/child_process:849:20)
at ChildProcess.target.send (node:internal/child_process:722:19)
at ChildProcessWorker.initialize (/Users/brrrrrr/.yarn/cache/jest-worker-npm-27.0.6-83200713fc-8d7ab8cdf6.zip/node_modules/jest-worker/build/workers/ChildProcessWorker.js:181:11)
at ChildProcessWorker._onExit (/Users/brrrrrr/.yarn/cache/jest-worker-npm-27.0.6-83200713fc-8d7ab8cdf6.zip/node_modules/jest-worker/build/workers/ChildProcessWorker.js:277:12)
at ChildProcess.emit (node:events:394:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
Emitted 'error' event on ChildProcess instance at:
at node:internal/child_process:853:39
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}
At some point, the error was gone, but i cannot reproduce the steps necessary to completely fix the issue.
This issue is related to macOS and nextjs >11 versions only as this error doesn’t pop up on other machines/versions.
Related: This project uses the pnp
packaging system from yarn version berry
Expected Behavior
The project should build.
To Reproduce
Calling next build
on macOS with next@11
Issue Analytics
- State:
- Created 2 years ago
- Reactions:21
- Comments:15 (8 by maintainers)
Top Results From Across the Web
write EPIPE when using ChildProcessWorker.js #10144 - GitHub
doWork (C:\src\web-2nd\node_modules\jest-worker\build\Farm.js:56:12) Emitted 'error' event at: at process.nextTick (internal/child_process.js: ...
Read more >events.js:288 Error: write EPIPE when executing tests with Jest
It turns out that by changing some libraries in package.json the error dissapears: Before (KO): "babel-jest": "^24.9.0", "jest": "^26.0.1",.
Read more >80% of the time build fails with Error: write EPIPE error
Building a JavaScript application using Create React App (yarn build) fails in ~80% of the time with the following error: Error: write EPIPE...
Read more >Gatsby Changelog | 5.3.0
By using a new <Slice /> React component in combination with a src/slices directory or createSlice API for common UI features, Gatsby will...
Read more >ts-node-dev - Bountysource
(node:10732) Warning: To load an ES module, set "type": "module" in the ... -example/node_modules/jest-worker/build/workers/ChildProcessWorker.js:264:15) at ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This option in
next.config.js
seems to resolve the issue for us:It affects how
new Worker
fromjest-worker
is created:https://github.com/vercel/next.js/blob/d60c95cb57497396d534eb8dd6fce9a192fc22fe/packages/next/build/index.ts#L675
experimental.cpus
is also used for other things like setting the parallelism for webpack build, see e.g. this full-text search:Specifically for jest-worker, it sets
numWorkers
in jest-worker here:On my machine which is MBP 16’’ 2019 with a 6-core Intel i7,
cpus().length
is 12 so jest-worker would then use 11 asnumWorkers
. Forexperimental.cpus
, I can use the values 1, 2 and 3 for the build to succeed ✅. 4 and above lead to that EPIPE error 🚫.The same problem! My build is running in docker and periodically crashes with this error!
Next.js: 11.0.1 Node.js: 14.17.3 Yarn: 2.4.2 (PnP)
Downgrading to version 10.2.3 solves the problem.
And yes, we’re on yarn 2 and PnP.