From 9ce204e27ed091bde5aa5bc9f82da41c80534bde Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Mon, 9 Oct 2023 13:16:12 +0200 Subject: [PATCH] fix: make sure discovery happens before auto-attach (#11100) --- .../puppeteer-core/src/cdp/ChromeTargetManager.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/puppeteer-core/src/cdp/ChromeTargetManager.ts b/packages/puppeteer-core/src/cdp/ChromeTargetManager.ts index f857e28f4da..97a72a947f4 100644 --- a/packages/puppeteer-core/src/cdp/ChromeTargetManager.ts +++ b/packages/puppeteer-core/src/cdp/ChromeTargetManager.ts @@ -127,14 +127,6 @@ export class ChromeTargetManager this.#onSessionDetached ); this.#setupAttachmentListeners(this.#connection); - - this.#connection - .send('Target.setDiscoverTargets', { - discover: true, - filter: this.#discoveryFilter, - }) - .then(this.#storeExistingTargetsForInit) - .catch(debugError); } #storeExistingTargetsForInit = () => { @@ -163,6 +155,13 @@ export class ChromeTargetManager }; async initialize(): Promise { + await this.#connection.send('Target.setDiscoverTargets', { + discover: true, + filter: this.#discoveryFilter, + }); + + this.#storeExistingTargetsForInit(); + await this.#connection.send('Target.setAutoAttach', { waitForDebuggerOnStart: true, flatten: true,