From 923434bd56df78050d7a09d3096fda84208f5b82 Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:31:41 +0100 Subject: [PATCH] chore: emit CDP event only on CdpSession (#11393) --- packages/puppeteer-core/src/bidi/Connection.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/puppeteer-core/src/bidi/Connection.ts b/packages/puppeteer-core/src/bidi/Connection.ts index 5e19197975f..4948704207f 100644 --- a/packages/puppeteer-core/src/bidi/Connection.ts +++ b/packages/puppeteer-core/src/bidi/Connection.ts @@ -221,6 +221,12 @@ export class BidiConnection extends EventEmitter { ); return; case 'event': + if (isCdpEvent(object)) { + cdpSessions + .get(object.params.session) + ?.emit(object.params.event, object.params.params); + return; + } this.#maybeEmitOnContext(object); // SAFETY: We know the method and parameter still match here. this.emit( @@ -244,10 +250,6 @@ export class BidiConnection extends EventEmitter { event.params.source.context !== undefined ) { context = this.#browsingContexts.get(event.params.source.context); - } else if (isCdpEvent(event)) { - cdpSessions - .get(event.params.session) - ?.emit(event.params.event, event.params.params); } context?.emit(event.method, event.params); }