Skip to content

Commit 4a62a61

Browse files
authored
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: #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>
1 parent 3257a36 commit 4a62a61

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

test/common/child_process.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ function expectSyncExit(caller, spawnArgs, {
8080
function logAndThrow() {
8181
const tag = `[process ${child.pid}]:`;
8282
console.error(`${tag} --- stderr ---`);
83-
console.error(stderrStr === undefined ? child.stderr.toString() : stderrStr);
83+
console.error(stderrStr === undefined ? (child.stderr?.toString() ?? '') : stderrStr);
8484
console.error(`${tag} --- stdout ---`);
85-
console.error(stdoutStr === undefined ? child.stdout.toString() : stdoutStr);
85+
console.error(stdoutStr === undefined ? (child.stdout?.toString() ?? '') : stdoutStr);
8686
console.error(`${tag} status = ${child.status}, signal = ${child.signal}`);
8787

8888
const error = new Error(`${failures.join('\n')}`);

0 commit comments

Comments
 (0)