From 11e9e83f8885083ee28c75bc395eb694842564ab Mon Sep 17 00:00:00 2001 From: Kamalpreet Kaur Date: Fri, 1 Mar 2024 00:08:51 +0530 Subject: [PATCH] fix(playwright-core): async android close method in connect flow --- packages/playwright-core/src/client/android.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/playwright-core/src/client/android.ts b/packages/playwright-core/src/client/android.ts index 296a596977..fb87601098 100644 --- a/packages/playwright-core/src/client/android.ts +++ b/packages/playwright-core/src/client/android.ts @@ -118,6 +118,7 @@ export class AndroidDevice extends ChannelOwner i readonly _timeoutSettings: TimeoutSettings; private _webViews = new Map(); _shouldCloseConnectionOnClose = false; + private _closedPromise: Promise; static from(androidDevice: channels.AndroidDeviceChannel): AndroidDevice { return (androidDevice as any)._object; @@ -129,6 +130,7 @@ export class AndroidDevice extends ChannelOwner i super(parent, type, guid, initializer); this.input = new AndroidInput(this); this._timeoutSettings = new TimeoutSettings((parent as Android)._timeoutSettings); + this._closedPromise = new Promise(f => this.once(Events.Browser.Disconnected, f)); this._channel.on('webViewAdded', ({ webView }) => this._onWebViewAdded(webView)); this._channel.on('webViewRemoved', ({ socketName }) => this._onWebViewRemoved(socketName)); this._channel.on('close', () => this._didClose()); @@ -244,6 +246,7 @@ export class AndroidDevice extends ChannelOwner i this._connection.close(); else await this._channel.close(); + await this._closedPromise; } catch (e) { if (isTargetClosedError(e)) return;