From 4a561f12dbae5a49203eb2c08fed71d9d0dfeb99 Mon Sep 17 00:00:00 2001 From: zuisong <19145952+zuisong@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:42:35 +0800 Subject: fix(node/child_process): don't crash on undefined/null value of an env var (#20378) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #20373 --------- Co-authored-by: Bartek IwaƄczuk --- ext/node/polyfills/internal/child_process.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ext/node/polyfills/internal') diff --git a/ext/node/polyfills/internal/child_process.ts b/ext/node/polyfills/internal/child_process.ts index b11281fd7..33b0b3166 100644 --- a/ext/node/polyfills/internal/child_process.ts +++ b/ext/node/polyfills/internal/child_process.ts @@ -53,6 +53,13 @@ export function mapValues( const entries = Object.entries(record); for (const [key, value] of entries) { + if (typeof value === "undefined") { + continue; + } + if (value === null) { + continue; + } + const mappedValue = transformer(value); ret[key] = mappedValue; @@ -836,7 +843,7 @@ export function spawnSync( const output = new Deno.Command(command, { args, cwd, - env, + env: mapValues(env, (value) => value.toString()), stdout: toDenoStdio(normalizedStdio[1]), stderr: toDenoStdio(normalizedStdio[2]), uid, -- cgit v1.2.3