mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(driver): make sure IpcTransport messages arrive in different tasks (#15978)
This commit is contained in:
parent
f067d1ddd6
commit
09461f8a76
@ -106,17 +106,18 @@ export class PipeTransport {
|
|||||||
|
|
||||||
export class IpcTransport {
|
export class IpcTransport {
|
||||||
private _process: NodeJS.Process | ChildProcess;
|
private _process: NodeJS.Process | ChildProcess;
|
||||||
|
private _waitForNextTask = makeWaitForNextTask();
|
||||||
onmessage?: (message: string) => void;
|
onmessage?: (message: string) => void;
|
||||||
onclose?: () => void;
|
onclose?: () => void;
|
||||||
|
|
||||||
constructor(process: NodeJS.Process | ChildProcess) {
|
constructor(process: NodeJS.Process | ChildProcess) {
|
||||||
this._process = process;
|
this._process = process;
|
||||||
this._process.on('message', message => {
|
this._process.on('message', message => this._waitForNextTask(() => {
|
||||||
if (message === '<eof>')
|
if (message === '<eof>')
|
||||||
this.onclose?.();
|
this.onclose?.();
|
||||||
else
|
else
|
||||||
this.onmessage?.(message);
|
this.onmessage?.(message);
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
send(message: string) {
|
send(message: string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user