From fdbbf0ae6dacbf1a0f4ca8e5bbb31c7804504ef1 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 7 Jul 2026 13:53:52 +0200 Subject: [PATCH] test: handle null stdio streams in spawnSyncAndAssert helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 PR-URL: https://github.com/nodejs/node/pull/64273 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Gürgün Dayıoğlu --- 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 d8c957bdf09..c74154bb084 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')}`);