From 4cf2caa47a3d6be5482297a65ef07b29d68444ff Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Tue, 20 Oct 2015 09:39:23 -0700 Subject: [PATCH] fix(launcher) workers fail to launch after tunnel In some environments, the process which establishes the tunnel can report that it is operational significantly before the tunnel is actually established. This will cause subsequent calls to create a worker to fail. This change waits a short interval after the tunnel process has reported itself started to allow it to actually finish establishing the tunnel before attempting to create any workers. Fixes karma-runner/karma-browserstack-launcher#42 --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 7b22457..b31070e 100644 --- a/index.js +++ b/index.js @@ -38,14 +38,16 @@ var createBrowserStackTunnel = function (logger, config, emitter) { log.error('Can not establish the tunnel.\n%s', error.toString()) deferred.reject(error) } else { - log.debug('Tunnel established.') - deferred.resolve() + setTimeout(function() { + log.debug('Tunnel established.') + deferred.resolve() + }, 2000) // Give the tunnel time to become actually established } }) emitter.on('exit', function (done) { log.debug('Shutting down the tunnel.') - tunnel.stop(function (error) { + tunnel.stop(function(error) { if (error) { log.error(error) }