Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(driver): do not crash on EPIPE after the client exits (#43499)

Pavel Feldman0acfc8722d84
diff --git a/packages/playwright-core/src/cli/driver.ts b/packages/playwright-core/src/cli/driver.ts
index b389d9f800..619ca44c84 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';