From 908ad6921f38a19102eaa798d8b1a85b8fd8ec3a Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 25 Jun 2021 00:54:06 +0200 Subject: [PATCH] fix(test-runner): make it compatible when running as a sub-process (#7298) Works around the following bug: https://github.com/nodejs/node/issues/12921 --- src/test/runner.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/test/runner.ts b/src/test/runner.ts index 591b9ddbd5..18e22f8801 100644 --- a/src/test/runner.ts +++ b/src/test/runner.ts @@ -109,14 +109,9 @@ export class Runner { async _flushOutput() { // Calling process.exit() might truncate large stdout/stderr output. // See https://github.com/nodejs/node/issues/6456. - // - // We can use writableNeedDrain to workaround this, but it is only available - // since node v15.2.0. - // See https://nodejs.org/api/stream.html#stream_writable_writableneeddrain. - if ((process.stdout as any).writableNeedDrain) - await new Promise(f => process.stdout.on('drain', f)); - if ((process.stderr as any).writableNeedDrain) - await new Promise(f => process.stderr.on('drain', f)); + // See https://github.com/nodejs/node/issues/12921 + await new Promise(resolve => process.stdout.write('', () => resolve())); + await new Promise(resolve => process.stderr.write('', () => resolve())); } async _run(list: boolean, testFileReFilters: FilePatternFilter[], projectName?: string): Promise {