fix(driver): make sure IpcTransport messages arrive in different tasks (#15978)

This commit is contained in:
Dmitry Gozman 2022-07-26 18:42:02 -07:00 committed by GitHub
parent f067d1ddd6
commit 09461f8a76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {