From 095dce052b3085dcee0be09ef509d815bff93fce Mon Sep 17 00:00:00 2001 From: Wil Wilsman Date: Wed, 2 Mar 2022 12:20:58 -0600 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20Move=20browser=20timeout=20default?= =?UTF-8?q?=20to=20other=20launch=20option=20defaults=20(#806)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/browser.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/core/src/browser.js b/packages/core/src/browser.js index 1343aebfd..421fa190f 100644 --- a/packages/core/src/browser.js +++ b/packages/core/src/browser.js @@ -70,10 +70,10 @@ export class Browser extends EventEmitter { constructor({ executable = process.env.PERCY_BROWSER_EXECUTABLE, + timeout = 30000, headless = true, cookies = [], - args = [], - timeout + args = [] }) { super(); @@ -115,8 +115,7 @@ export class Browser extends EventEmitter { }); // connect a websocket to the devtools address - let addr = await this.address(this.launchTimeout); - this.ws = new WebSocket(addr, { perMessageDeflate: false }); + this.ws = new WebSocket(await this.address(), { perMessageDeflate: false }); // wait until the websocket has connected await new Promise(resolve => this.ws.once('open', resolve)); @@ -240,7 +239,7 @@ export class Browser extends EventEmitter { // Returns the devtools websocket address. If not already known, will watch the browser's // stderr and resolves when it emits the devtools protocol address or rejects if the process // exits for any reason or if the address does not appear after the timeout. - async address(timeout = 30000) { + async address(timeout = this.launchTimeout) { this._address ||= await new Promise((resolve, reject) => { let stderr = '';