From 828d6f19c713bf9478a9f012e05371572f248f2e Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Wed, 24 Jun 2026 16:40:38 -0700 Subject: [PATCH 1/2] fix(reporters): do not truncate piped output on exit StripAnsiStream buffered chunks in the Writable internal queue and forwarded them to the target stream asynchronously via _write. When the runner exits via process.exit() before those chunks are flushed, the tail of the output is lost on large suites when piped/redirected. Forward synchronously to the target instead. Fixes https://github.com/microsoft/playwright/issues/41449 --- packages/playwright/src/reporters/base.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts index 5a0702087085d..279da8d1823ca 100644 --- a/packages/playwright/src/reporters/base.ts +++ b/packages/playwright/src/reporters/base.ts @@ -86,8 +86,12 @@ class StripAnsiStream extends Writable { this._target = target; } - override _write(chunk: any, encoding: any, callback: any) { - this._target.write(stripAnsiEscapes(chunk.toString()), callback); + // Forward synchronously to the target stream instead of going through the + // Writable internal buffer. Otherwise chunks queued here can be lost when the + // process exits via process.exit() before they are flushed to the target. + override write(chunk: any, encodingOrCallback?: any, callback?: any): boolean { + const cb = typeof encodingOrCallback === 'function' ? encodingOrCallback : callback; + return this._target.write(stripAnsiEscapes(chunk.toString()), cb); } } From 5c135c1cd980f0ace47fc5716aa0ad300d254499 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Thu, 25 Jun 2026 10:24:21 -0700 Subject: [PATCH 2/2] Update base.ts --- packages/playwright/src/reporters/base.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts index 279da8d1823ca..e1d0737af599b 100644 --- a/packages/playwright/src/reporters/base.ts +++ b/packages/playwright/src/reporters/base.ts @@ -86,9 +86,6 @@ class StripAnsiStream extends Writable { this._target = target; } - // Forward synchronously to the target stream instead of going through the - // Writable internal buffer. Otherwise chunks queued here can be lost when the - // process exits via process.exit() before they are flushed to the target. override write(chunk: any, encodingOrCallback?: any, callback?: any): boolean { const cb = typeof encodingOrCallback === 'function' ? encodingOrCallback : callback; return this._target.write(stripAnsiEscapes(chunk.toString()), cb);