From 211ebc79bb7e74dc3f1a7fba7a60636e39da38b5 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Sat, 17 Oct 2026 16:00:42 -0700 Subject: [PATCH] fix(driver): do not crash on EPIPE after the client exits When a language binding exits while the driver still sends messages, the write to stdout fails with EPIPE. Without an error listener the driver crashes before it closes the browsers, so a launched browser can outlive the client. Ignore the error; the driver still exits gracefully when stdin closes. --- packages/playwright-core/src/cli/driver.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/playwright-core/src/cli/driver.ts b/packages/playwright-core/src/cli/driver.ts index b389d9f8002eb..619ca44c846db 100644 --- a/packages/playwright-core/src/cli/driver.ts +++ b/packages/playwright-core/src/cli/driver.ts @@ -35,6 +35,10 @@ export function runDriver() { }); // eslint-disable-next-line no-restricted-properties const transport = new PipeTransport(process.stdout, process.stdin); + // The client may exit while messages are still in flight. Ignore the EPIPE so the + // driver keeps running until stdin closes, and then closes the browsers gracefully. + // eslint-disable-next-line no-restricted-properties + process.stdout.on('error', () => {}); transport.onmessage = (message: string) => dispatcherConnection.dispatch(JSON.parse(message)); // Certain Language Binding JSON parsers (e.g. .NET) do not like strings with lone surrogates. const isJavaScriptLanguageBinding = !process.env.PW_LANG_NAME || process.env.PW_LANG_NAME === 'javascript';