From 9431272c12670ef430f91001b628a8ee4d38a8c5 Mon Sep 17 00:00:00 2001 From: SuperOleg39 Date: Mon, 29 Nov 2021 18:23:55 +0200 Subject: [PATCH 1/4] jest-worker: Avoid crash when "--max-old-space-size" inside process.execArgv --- packages/jest-worker/src/workers/NodeThreadsWorker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-worker/src/workers/NodeThreadsWorker.ts b/packages/jest-worker/src/workers/NodeThreadsWorker.ts index da6c3741b6b0..6a9b9930ab78 100644 --- a/packages/jest-worker/src/workers/NodeThreadsWorker.ts +++ b/packages/jest-worker/src/workers/NodeThreadsWorker.ts @@ -65,7 +65,7 @@ export default class ExperimentalWorker implements WorkerInterface { JEST_WORKER_ID: String(this._options.workerId + 1), // 0-indexed workerId, 1-indexed JEST_WORKER_ID }, eval: false, - execArgv: process.execArgv, + execArgv: process.execArgv.filter(v => !/^--(max_old_space_size)/.test(v)), // @ts-expect-error: added in newer versions resourceLimits: this._options.resourceLimits, stderr: true, From a5957056d90c30c15508733d2472271083950dce Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 30 Nov 2021 08:56:03 +0100 Subject: [PATCH 2/4] Update NodeThreadsWorker.ts --- packages/jest-worker/src/workers/NodeThreadsWorker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/jest-worker/src/workers/NodeThreadsWorker.ts b/packages/jest-worker/src/workers/NodeThreadsWorker.ts index 6a9b9930ab78..d4f0e371216f 100644 --- a/packages/jest-worker/src/workers/NodeThreadsWorker.ts +++ b/packages/jest-worker/src/workers/NodeThreadsWorker.ts @@ -65,7 +65,8 @@ export default class ExperimentalWorker implements WorkerInterface { JEST_WORKER_ID: String(this._options.workerId + 1), // 0-indexed workerId, 1-indexed JEST_WORKER_ID }, eval: false, - execArgv: process.execArgv.filter(v => !/^--(max_old_space_size)/.test(v)), + // Suppress --debug / --inspect / --max_old_space_size flags while preserving others (like --harmony). + execArgv: process.execArgv.filter(v => !/^--(debug|inspect|max_old_space_size)/.test(v)), // @ts-expect-error: added in newer versions resourceLimits: this._options.resourceLimits, stderr: true, From b1107483e300482e5b0f7c8642286a8cbc0f9cd3 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 30 Nov 2021 08:59:21 +0100 Subject: [PATCH 3/4] eslint and changelog --- CHANGELOG.md | 3 +++ packages/jest-worker/src/workers/NodeThreadsWorker.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ca7f7a06dde..0098e4f7d9e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Fixes +- `[jest-worker]` Filter `execArgv` correctly ([#12097](https://github.com/facebook/jest/pull/12097)) + ### Chore & Maintenance ### Performance @@ -27,6 +29,7 @@ - `[jest-environment-jsdom]` Add `@types/jsdom` dependency ([#11999](https://github.com/facebook/jest/pull/11999)) - `[jest-environment-jsdom]` Do not reset the global.document too early on teardown ([#11871](https://github.com/facebook/jest/pull/11871)) - `[jest-transform]` Improve error and warning messages ([#11998](https://github.com/facebook/jest/pull/11998)) +- `[jest-worker]` Pass `execArgv` correctly to `worker_threads` worker ([#12069](https://github.com/facebook/jest/pull/12069)) ### Chore & Maintenance diff --git a/packages/jest-worker/src/workers/NodeThreadsWorker.ts b/packages/jest-worker/src/workers/NodeThreadsWorker.ts index d4f0e371216f..938172b050c6 100644 --- a/packages/jest-worker/src/workers/NodeThreadsWorker.ts +++ b/packages/jest-worker/src/workers/NodeThreadsWorker.ts @@ -66,7 +66,9 @@ export default class ExperimentalWorker implements WorkerInterface { }, eval: false, // Suppress --debug / --inspect / --max_old_space_size flags while preserving others (like --harmony). - execArgv: process.execArgv.filter(v => !/^--(debug|inspect|max_old_space_size)/.test(v)), + execArgv: process.execArgv.filter( + v => !/^--(debug|inspect|max_old_space_size)/.test(v), + ), // @ts-expect-error: added in newer versions resourceLimits: this._options.resourceLimits, stderr: true, From 113e3175fc0bcb33af5fce77f0c3c02e9fd4765a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 30 Nov 2021 09:10:42 +0100 Subject: [PATCH 4/4] comment --- packages/jest-worker/src/workers/NodeThreadsWorker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-worker/src/workers/NodeThreadsWorker.ts b/packages/jest-worker/src/workers/NodeThreadsWorker.ts index 938172b050c6..70551119b04b 100644 --- a/packages/jest-worker/src/workers/NodeThreadsWorker.ts +++ b/packages/jest-worker/src/workers/NodeThreadsWorker.ts @@ -65,9 +65,9 @@ export default class ExperimentalWorker implements WorkerInterface { JEST_WORKER_ID: String(this._options.workerId + 1), // 0-indexed workerId, 1-indexed JEST_WORKER_ID }, eval: false, - // Suppress --debug / --inspect / --max_old_space_size flags while preserving others (like --harmony). + // Suppress --max_old_space_size flags while preserving others (like --harmony). See https://nodejs.org/api/worker_threads.html#new-workerfilename-options execArgv: process.execArgv.filter( - v => !/^--(debug|inspect|max_old_space_size)/.test(v), + v => !/^--(max_old_space_size)/.test(v), ), // @ts-expect-error: added in newer versions resourceLimits: this._options.resourceLimits,