From 679c69a8a1af880e0d972f90ee02b9ede9e52e29 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 3 Jul 2026 23:26:51 +0200 Subject: [PATCH] test: handle null stdio streams in spawnSyncAndAssert helper When a test uses 'pipe' for the stdio but the child process crashes, the stream will be null. In this case, don't try to stringify it and instead log an empty string. Signed-off-by: Joyee Cheung --- test/common/child_process.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/common/child_process.js b/test/common/child_process.js index d8c957bdf09ce4..c74154bb084f32 100644 --- a/test/common/child_process.js +++ b/test/common/child_process.js @@ -80,9 +80,9 @@ function expectSyncExit(caller, spawnArgs, { function logAndThrow() { const tag = `[process ${child.pid}]:`; console.error(`${tag} --- stderr ---`); - console.error(stderrStr === undefined ? child.stderr.toString() : stderrStr); + console.error(stderrStr === undefined ? (child.stderr?.toString() ?? '') : stderrStr); console.error(`${tag} --- stdout ---`); - console.error(stdoutStr === undefined ? child.stdout.toString() : stdoutStr); + console.error(stdoutStr === undefined ? (child.stdout?.toString() ?? '') : stdoutStr); console.error(`${tag} status = ${child.status}, signal = ${child.signal}`); const error = new Error(`${failures.join('\n')}`);