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';