From d126e4164f00a35f4bbc6078e5a79045875329c9 Mon Sep 17 00:00:00 2001 From: Alex Lunyov Date: Wed, 9 May 2018 23:31:06 +0800 Subject: [PATCH] Do not recreate browser instance if getBrowser options passed --- src/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 506b9d76..6e56350a 100644 --- a/src/index.js +++ b/src/index.js @@ -39,8 +39,12 @@ const launchBrowserIfNeeded = async function ({ getBrowser }) { if (browser) { return } - if (getBrowser && typeof getBrowser === 'function') { - _browserLaunchPromise = Promise.resolve(getBrowser()) + if ( + getBrowser && + typeof getBrowser === 'function' && + !_browserLaunchPromise + ) { + _browserLaunchPromise = getBrowser() } if (!_browserLaunchPromise) { debuglog('no browser instance, launching new browser..')