From 2c87835628c1ee6ea9c20a6e46ca39ae68b03980 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 26 Sep 2025 17:11:12 +0000 Subject: [PATCH 1/2] process: fix default `env` for `process.execve` The `env` parameter for `process.execve` is documented to default to `process.env`. --- lib/internal/process/per_thread.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 07a94486169a7c..8ac941564e2e7b 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -279,7 +279,7 @@ function wrapProcessMethods(binding) { return true; } - function execve(execPath, args = [], env) { + function execve(execPath, args = [], env = process.env) { emitExperimentalWarning('process.execve'); const { isMainThread } = require('internal/worker'); From 7db323ee2f07c11efd5805bbfd8f4dcf54248ced Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 26 Sep 2025 18:45:44 +0000 Subject: [PATCH 2/2] fixup! process: fix default `env` for `process.execve` --- lib/internal/process/per_thread.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 8ac941564e2e7b..da2ba93e7e93ae 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -301,22 +301,20 @@ function wrapProcessMethods(binding) { } const envArray = []; - if (env !== undefined) { - validateObject(env, 'env'); - - for (const { 0: key, 1: value } of ObjectEntries(env)) { - if ( - typeof key !== 'string' || - typeof value !== 'string' || - StringPrototypeIncludes(key, '\u0000') || - StringPrototypeIncludes(value, '\u0000') - ) { - throw new ERR_INVALID_ARG_VALUE( - 'env', env, 'must be an object with string keys and values without null bytes', - ); - } else { - ArrayPrototypePush(envArray, `${key}=${value}`); - } + validateObject(env, 'env'); + + for (const { 0: key, 1: value } of ObjectEntries(env)) { + if ( + typeof key !== 'string' || + typeof value !== 'string' || + StringPrototypeIncludes(key, '\u0000') || + StringPrototypeIncludes(value, '\u0000') + ) { + throw new ERR_INVALID_ARG_VALUE( + 'env', env, 'must be an object with string keys and values without null bytes', + ); + } else { + ArrayPrototypePush(envArray, `${key}=${value}`); } }