Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest-worker: Avoid crash when "--max-old-space-size" inside process.execArgv #12097

Merged
merged 4 commits into from
Nov 30, 2021

Conversation

SuperOleg39
Copy link
Contributor

@SuperOleg39 SuperOleg39 commented Nov 29, 2021

jest-worker used by terser-webpack-plugin

In our cli, we run build process with max-old-space-size flag by default, and use terser-webpack-plugin inside.

So, terser-webpack-plugin initialize ExperimentalWorker, and ExperimentalWorker pass max-old-space-size to NodeJS worker, then process failed with error:

error GLOBAL:ERROR Error: platform.3c72a39d93fe42d9bfb2.js from Terser plugin
Initiated Worker with invalid execArgv flags: --max_old_space_size=3000
Error [ERR_WORKER_INVALID_EXEC_ARGV]: Initiated Worker with invalid execArgv flags: --max_old_space_size=3000
    at new NodeError (node:internal/errors:371:5)
    at new Worker (node:internal/worker:191:13)
    at ExperimentalWorker.initialize (/builds/coretech-frontend/tramvai/smokeNpm/node_modules/jest-worker/build/workers/NodeThreadsWorker.js:149:20)
    at new ExperimentalWorker (/builds/coretech-frontend/tramvai/smokeNpm/node_modules/jest-worker/build/workers/NodeThreadsWorker.js:145:10)
    at WorkerPool.createWorker (/builds/coretech-frontend/tramvai/smokeNpm/node_modules/jest-worker/build/WorkerPool.js:44:12)
    at new BaseWorkerPool (/builds/coretech-frontend/tramvai/smokeNpm/node_modules/jest-worker/build/base/BaseWorkerPool.js:127:27)
    at new WorkerPool (/builds/coretech-frontend/tramvai/smokeNpm/node_modules/jest-worker/build/WorkerPool.js:30:1)
    at new Worker (/builds/coretech-frontend/tramvai/smokeNpm/node_modules/jest-worker/build/index.js:167:26)
    at getWorker (/builds/coretech-frontend/tramvai/smokeNpm/node_modules/terser-webpack-plugin/dist/index.js:391:9)
    at /builds/coretech-frontend/tramvai/smokeNpm/node_modules/terser-webpack-plugin/dist/index.js:494:41

@SuperOleg39
Copy link
Contributor Author

@kherock hi!

Fyi, change the code from you last commit, maybe you can help with review?

@SuperOleg39
Copy link
Contributor Author

Found old PR with similar problem - https://github.com/parcel-bundler/parcel/pull/5017/files

@codecov-commenter
Copy link

Codecov Report

Merging #12097 (9431272) into main (40a9027) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12097      +/-   ##
==========================================
- Coverage   68.91%   68.90%   -0.01%     
==========================================
  Files         324      324              
  Lines       16681    16682       +1     
  Branches     4814     4814              
==========================================
  Hits        11495    11495              
- Misses       5153     5154       +1     
  Partials       33       33              
Impacted Files Coverage Δ
...kages/jest-worker/src/workers/NodeThreadsWorker.ts 93.61% <100.00%> (+0.06%) ⬆️
packages/expect/src/utils.ts 96.03% <0.00%> (-0.50%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40a9027...9431272. Read the comment docs.

Copy link
Contributor

@kherock kherock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me. I'd suggest adding a unit test assertion for this, there's a similar one you can borrow testing --inspect in the child process worker test file.

@poman31
Copy link

poman31 commented Nov 29, 2021

I am also seeing this error as of 27.4.0 version of jest-worker and angular 12 cli. Had to downgrade to jest-worker 27.3.1 to fix the compilation failure

styles.b2ce177b96dbbf74326c.css - Error: styles.b2ce177b96dbbf74326c.css from Css Minimizer Error [ERR_WORKER_INVALID_EXEC_ARGV]: Initiated Worker with invalid execArgv flags: --max_old_space_size=4096 at new NodeError (internal/errors.js:322:7) at new Worker (internal/worker.js:196:13) at ExperimentalWorker.initialize (C:\Users\ed\IdeaProjects\assist2-web\node_modules\jest-worker\build\workers\NodeThreadsWorker.js:149:20) at new ExperimentalWorker (C:\Users\ed\IdeaProjects\assist2-web\node_modules\jest-worker\build\workers\NodeThreadsWorker.js:145:10) at WorkerPool.createWorker (C:\Users\ed\IdeaProjects\assist2-web\node_modules\jest-worker\build\WorkerPool.js:44:12) at new BaseWorkerPool (C:\Users\ed\IdeaProjects\assist2-web\node_modules\jest-worker\build\base\BaseWorkerPool.js:127:27) at new WorkerPool (C:\Users\ed\IdeaProjects\assist2-web\node_modules\jest-worker\build\WorkerPool.js:30:1) at new Worker (C:\Users\ed\IdeaProjects\assist2-web\node_modules\jest-worker\build\index.js:167:26) at getWorker (C:\Users\ed\IdeaProjects\assist2-web\node_modules\css-minimizer-webpack-plugin\dist\index.js:192:29) at C:\Users\ed\IdeaProjects\assist2-web\node_modules\css-minimizer-webpack-plugin\dist\index.js:262:41

@simplejason
Copy link

I faced same error in angular 12 cli, and also it was proved that the problem was caused by 27.4.0:

styles.40679d291cbf2b600aeb.css - Error: styles.40679d291cbf2b600aeb.css from Css Minimizer
Error [ERR_WORKER_INVALID_EXEC_ARGV]: Initiated Worker with invalid execArgv flags: --max_old_space_size=4096
    at new NodeError (internal/errors.js:322:7)
    at new Worker (internal/worker.js:196:13)
    at ExperimentalWorker.initialize (/home/vsts/work/1/s/node_modules/jest-worker/build/workers/NodeThreadsWorker.js:149:20)
    at new ExperimentalWorker (/home/vsts/work/1/s/node_modules/jest-worker/build/workers/NodeThreadsWorker.js:145:10)
    at WorkerPool.createWorker (/home/vsts/work/1/s/node_modules/jest-worker/build/WorkerPool.js:44:12)
    at new BaseWorkerPool (/home/vsts/work/1/s/node_modules/jest-worker/build/base/BaseWorkerPool.js:127:27)
    at new WorkerPool (/home/vsts/work/1/s/node_modules/jest-worker/build/WorkerPool.js:30:1)
    at new Worker (/home/vsts/work/1/s/node_modules/jest-worker/build/index.js:167:26)
    at getWorker (/home/vsts/work/1/s/node_modules/css-minimizer-webpack-plugin/dist/index.js:192:29)
    at /home/vsts/work/1/s/node_modules/css-minimizer-webpack-plugin/dist/index.js:262:41
    at /home/vsts/work/1/s/node_modules/css-minimizer-webpack-plugin/node_modules/p-limit/index.js:23:31
    at run (/home/vsts/work/1/s/node_modules/css-minimizer-webpack-plugin/node_modules/p-limit/index.js:23:43)
    at /home/vsts/work/1/s/node_modules/css-minimizer-webpack-plugin/node_modules/p-limit/index.js:45:20

@SimenB SimenB changed the title jest-worker: Avoid crash when "--max-old-space-size" inside process.execArgv jest-worker: Avoid crash when "--max-old-space-size" inside process.execArgv Nov 30, 2021
@SimenB SimenB merged commit 7fead59 into jestjs:main Nov 30, 2021
@SimenB
Copy link
Member

SimenB commented Nov 30, 2021

https://github.com/facebook/jest/releases/tag/v27.4.1

@JonWallsten
Copy link
Contributor

@kherock @SimenB: According to Node's official documentation hyphens are supposed to be used, not undescore. We used underscore before but are now using hyphens. Can we patch both?
Source:
https://nodejs.org/api/cli.html#cli_max_old_space_size_size_in_megabytes

@SimenB
Copy link
Member

SimenB commented Nov 30, 2021

PR welcome

@SuperOleg39
Copy link
Contributor Author

This seems fine to me. I'd suggest adding a unit test assertion for this, there's a similar one you can borrow testing --inspect in the child process worker test file.

Didn't get to add test(

https://github.com/facebook/jest/releases/tag/v27.4.1

Thanks!

According to Node's official documentation hyphens are supposed to be used, not undescore. We used underscore before but are now using hyphens. Can we patch both?

Good catch, thanks!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants