mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: use setImmediate to reduce flakiness when processing events (#12264)
This commit is contained in:
parent
ff4f70f4ae
commit
73403b323e
@ -41,14 +41,18 @@ export class NodeWebSocketTransport implements ConnectionTransport {
|
|||||||
constructor(ws: NodeWebSocket) {
|
constructor(ws: NodeWebSocket) {
|
||||||
this.#ws = ws;
|
this.#ws = ws;
|
||||||
this.#ws.addEventListener('message', event => {
|
this.#ws.addEventListener('message', event => {
|
||||||
if (this.onmessage) {
|
setImmediate(() => {
|
||||||
this.onmessage.call(null, event.data);
|
if (this.onmessage) {
|
||||||
}
|
this.onmessage.call(null, event.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
this.#ws.addEventListener('close', () => {
|
this.#ws.addEventListener('close', () => {
|
||||||
if (this.onclose) {
|
setImmediate(() => {
|
||||||
this.onclose.call(null);
|
if (this.onclose) {
|
||||||
}
|
this.onclose.call(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
// Silently ignore all errors - we don't know what to do with them.
|
// Silently ignore all errors - we don't know what to do with them.
|
||||||
this.#ws.addEventListener('error', () => {});
|
this.#ws.addEventListener('error', () => {});
|
||||||
|
Loading…
Reference in New Issue
Block a user