Skip to content

Commit

Permalink
fix: Add small startup delay to fix connection failures
Browse files Browse the repository at this point in the history
If the external driver binary doesn't start listening quickly enough, it's
possible for the client to connection too soon and have its connection refused.
This adds a brief (2s) delay before connecting, to give the external driver
time to start up.  This happens to be enough time on my Mac, on which the
drivers happen to start slowly enough for this issue to occur in the first
place.
  • Loading branch information
joeyparrish committed Feb 3, 2022
1 parent 5cbebe6 commit 03918e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ const LocalWebDriverBase = function(
log.debug('[http] ' + meth + ' ' + path + ' ' + (data || ''));
});

this.on('start', (url) => {
this.on('start', async (url) => {
await new Promise((resolve) => setTimeout(resolve, 2000));

this.browser.init(this.spec, (error) => {
if (error) {
log.error(`Could not connect to ${this.browserName} WebDriver`);
Expand Down

0 comments on commit 03918e3

Please sign in to comment.