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): make sure IpcTransport messages arrive in different tasks (#15978)

Dmitry Gozman09461f8a7680
diff --git a/packages/playwright-core/src/protocol/transport.ts b/packages/playwright-core/src/protocol/transport.ts
index 8026f00c21..92991af7ae 100644
--- a/packages/playwright-core/src/protocol/transport.ts
+++ b/packages/playwright-core/src/protocol/transport.ts
@@ -106,17 +106,18 @@ export class PipeTransport {
export class IpcTransport {
private _process: NodeJS.Process | ChildProcess;
+ private _waitForNextTask = makeWaitForNextTask();
onmessage?: (message: string) => void;
onclose?: () => void;
constructor(process: NodeJS.Process | ChildProcess) {
this._process = process;
- this._process.on('message', message => {
+ this._process.on('message', message => this._waitForNextTask(() => {
if (message === '<eof>')
this.onclose?.();
else
this.onmessage?.(message);
- });
+ }));
}
send(message: string) {