question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jest-worker 27.4.0 breaks webpack builds with node options

See original GitHub issue

Bug report

When latest webpack is used with latest jest - 27.4.0, it breaks production builds with custom node options. e.g. node --max_old_space_size=2768 node_modules/webpack-cli/bin/cli.js --mode production

Result is

ERROR in 497.a3d1.js from Terser
Error [ERR_WORKER_INVALID_EXEC_ARGV]: Initiated Worker with invalid execArgv flags: --max_old_space_size=2768
    at new NodeError (internal/errors.js:322:7)
    at new Worker (internal/worker.js:196:13)
    at ExperimentalWorker.initialize (/permissions/node_modules/jest-worker/build/workers/NodeThreadsWorker.js:149:20)
    at new ExperimentalWorker (/permissions/node_modules/jest-worker/build/workers/NodeThreadsWorker.js:145:10)
    at WorkerPool.createWorker (/permissions/node_modules/jest-worker/build/WorkerPool.js:44:12)
    at new BaseWorkerPool (/permissions/node_modules/jest-worker/build/base/BaseWorkerPool.js:127:27)
    at new WorkerPool (/permissions/node_modules/jest-worker/build/WorkerPool.js:30:1)
    at new Worker (/permissions/node_modules/jest-worker/build/index.js:167:26)
    at getWorker (/permissions/node_modules/terser-webpack-plugin/dist/index.js:288:9)
    at /permissions/node_modules/terser-webpack-plugin/dist/index.js:389:41

Problem is with latest jest-worker. There is installed tree with npm

$ npm ls jest-worker
permissions@1.0.0 ./src
├─┬ babel-jest@27.4.0
│ └─┬ @jest/transform@27.4.0
│   └─┬ jest-haste-map@27.4.0
│     └── jest-worker@27.4.0 deduped
├─┬ jest@27.4.0
│ └─┬ @jest/core@27.4.0
│   ├─┬ @jest/reporters@27.4.0
│   │ └── jest-worker@27.4.0 deduped
│   └─┬ jest-runner@27.4.0
│     └── jest-worker@27.4.0 deduped
└─┬ webpack@5.64.4
  └─┬ terser-webpack-plugin@5.1.4
    └── jest-worker@27.4.0

If the current behavior is a bug, please provide the steps to reproduce.

Install latest webpack with latest jest Use some simple webpack config which utilizes production build. I can try it later for minimal setup if necessary.

What is the expected behavior?

Production builds work as expected. Lowering jest-worker dependency can be solution.

Other relevant information: webpack version: 5.64.4 Node.js version: 16.13.0 Operating System: Windows, Linux Additional tools: jest@27.4.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
MirKmlcommented, Nov 29, 2021

Temporary workaround - install jest-worker@27.3.* by hand. Then webpack production builds with node options works as usually. $ npm i -D jest-worker@27.3.1 $ node --max_old_space_size=2768 node_modules/webpack-cli/bin/cli.js --mode production

assets by info 5.72 MiB [immutable]
  assets by path *.js 3.07 MiB 4 assets
  assets by path *.svg 1.64 MiB 4 assets
  assets by path *.eot 343 KiB 3 assets
  assets by path *.ttf 342 KiB 3 assets
  assets by path *.woff 196 KiB 3 assets
....
Entrypoints:
  main (3.14 MiB)
      main.css
      main.1ed2.js

webpack 5.64.4 compiled with 2 warnings in 25863 ms

But I think it’s up to webpack developers fix erroneous dependency. Or create issue on jest. It’s news to me, that jest-worker is wepback dependency.

2reactions
DzmVasileuskycommented, Dec 9, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

how solve error jest-worker at run build? - Stack Overflow
It worked when I downgraded terser-webpack-plugin to 2.3.6. So you'll probably have to upgrade your Node.js if you're using a version earlier ...
Read more >
jest-worker - npm
Module for executing heavy tasks under forked processes in parallel, by providing a `Promise` based interface, minimum overhead, ...
Read more >
jest-worker | Yarn - Package Manager
Module for executing heavy tasks under forked processes in parallel, by providing a Promise based interface, minimum overhead, and bound workers. The module ......
Read more >
Watch and WatchOptions | webpack
Turn on watch mode. This means that after the initial build, webpack will continue to watch for changes in any of the resolved...
Read more >
Debugging random Node.js build failures - CircleCI Discuss
You can check an option to serially run your Node.js package on a documentation. If you use popular packages such as Jest and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found