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 RafaelGSS committed 2026-07-29 10:31:22 -03:00
1 parent 10ea17dafe
commit fdbbf0ae6d
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')}`);