From 03918e374b89769ba769f5bc14fe440b3f05a494 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 2 Feb 2022 20:06:05 -0800 Subject: [PATCH] fix: Add small startup delay to fix connection failures 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. --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 204db8e..6e5429c 100644 --- a/index.js +++ b/index.js @@ -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`);