Skip to content

Commit

Permalink
♻ Move browser timeout default to other launch option defaults (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwilsman authored Mar 2, 2022
1 parent 521cda2 commit 095dce0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 = '';

Expand Down

0 comments on commit 095dce0

Please sign in to comment.