diff --git a/test/parallel/test-child-process-flush-stdio.js b/test/parallel/test-child-process-flush-stdio.js index c2cae2069a8ce5..e75f1d5e5048cc 100644 --- a/test/parallel/test-child-process-flush-stdio.js +++ b/test/parallel/test-child-process-flush-stdio.js @@ -26,8 +26,10 @@ function spawnWithReadable() { assert.strictEqual(Buffer.concat(buffer).toString().trim(), '123'); })); p.stdout.on('readable', function() { - let buf; - while (buf = this.read()) - buffer.push(buf); + setImmediate(() => { + let buf; + while (buf = this.read()) + buffer.push(buf); + }); }); }