Skip to content

Commit 2b31ee1

Browse files
authored
fix(pool): propagate parent execArgv to worker processes (#1129)
1 parent c5e7e3d commit 2b31ee1

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

packages/core/src/pool/index.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,22 @@ export const createPool = async ({
168168
>;
169169
close: () => Promise<void>;
170170
}> => {
171-
// Some options may crash worker, e.g. --prof, --title.
171+
// Propagate parent execArgv to workers, except flags known to cause issues
172+
// in child processes (--prof writes per-worker profiling logs, --title is
173+
// meaningless for workers). Safe for child_process.fork; the referenced
174+
// Node.js issue (#41103) only affects worker_threads.
172175
// https://github.com/nodejs/node/issues/41103
173-
const execArgv = process.execArgv.filter(
174-
(execArg) =>
175-
execArg.startsWith('--perf') ||
176-
execArg.startsWith('--cpu-prof') ||
177-
execArg.startsWith('--heap-prof') ||
178-
execArg.startsWith('--diagnostic-dir'),
179-
);
176+
const blockedFlags = ['--prof', '--title'];
177+
const execArgv = process.execArgv.filter((arg, i, arr) => {
178+
if (blockedFlags.some((f) => arg === f || arg.startsWith(`${f}=`))) {
179+
return false;
180+
}
181+
// skip standalone value following --title (handles `--title foo` form)
182+
if (i > 0 && arr[i - 1] === '--title') {
183+
return false;
184+
}
185+
return true;
186+
});
180187

181188
const numCpus = getNumCpus();
182189

0 commit comments

Comments
 (0)