From 28c4a1697cf71922cbf790fe5d89b1eb9c2acf4f Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Wed, 5 Feb 2020 16:08:28 -0800 Subject: [PATCH] fix(chromium): ensure we resume service worker before detaching from it (#850) --- src/chromium/crPage.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chromium/crPage.ts b/src/chromium/crPage.ts index 0a2c574ee7..e74687d3b7 100644 --- a/src/chromium/crPage.ts +++ b/src/chromium/crPage.ts @@ -218,9 +218,10 @@ export class CRPage implements PageDelegate { _onAttachedToTarget(event: Protocol.Target.attachedToTargetPayload) { const session = CRConnection.fromSession(this._client).session(event.sessionId)!; if (event.targetInfo.type !== 'worker') { - // Ideally, detaching should resume any target, but there is bug in the backend. - session.send('Runtime.runIfWaitingForDebugger').catch(debugError); - this._client.send('Target.detachFromTarget', { sessionId: event.sessionId }).catch(debugError); + // Ideally, detaching should resume any target, but there is a bug in the backend. + session.send('Runtime.runIfWaitingForDebugger').catch(debugError).then(() => { + this._client.send('Target.detachFromTarget', { sessionId: event.sessionId }).catch(debugError); + }); return; } const url = event.targetInfo.url;