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 <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64273
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
This commit is contained in:
Joyee Cheung authored and GitHub committed 2026-07-07 11:53:52 +00:00
1 parent 3257a3601f
commit 4a62a61092
1 file changed
+2 -2
+2 -2
View File
@@ -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')}`);