From 113489d3b58e2907374a4e6e5133bf46630695d1 Mon Sep 17 00:00:00 2001 From: Jan Scheffler Date: Mon, 27 Sep 2021 10:01:35 +0200 Subject: [PATCH] fix(launcher): launcher.launch() should pass 'timeout' option #5180 (#7596) Co-authored-by: Bob Jamison --- src/node/Launcher.ts | 4 ++-- test/launcher.spec.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/node/Launcher.ts b/src/node/Launcher.ts index 27f3e1f2..615e9001 100644 --- a/src/node/Launcher.ts +++ b/src/node/Launcher.ts @@ -164,7 +164,7 @@ class ChromeLauncher implements ProductLauncher { runner.close.bind(runner) ); if (waitForInitialPage) - await browser.waitForTarget((t) => t.type() === 'page'); + await browser.waitForTarget((t) => t.type() === 'page', { timeout }); return browser; } catch (error) { runner.kill(); @@ -336,7 +336,7 @@ class FirefoxLauncher implements ProductLauncher { runner.close.bind(runner) ); if (waitForInitialPage) - await browser.waitForTarget((t) => t.type() === 'page'); + await browser.waitForTarget((t) => t.type() === 'page', { timeout }); return browser; } catch (error) { runner.kill(); diff --git a/test/launcher.spec.ts b/test/launcher.spec.ts index 5737d887..84113a4d 100644 --- a/test/launcher.spec.ts +++ b/test/launcher.spec.ts @@ -392,6 +392,15 @@ describe('Launcher specs', function () { await browser.close(); } ); + it('should pass the timeout parameter to browser.waitForTarget', async () => { + const { puppeteer, defaultBrowserOptions } = getTestState(); + const options = Object.assign({}, defaultBrowserOptions, { + timeout: 1, + }); + let error = null; + await puppeteer.launch(options).catch((error_) => (error = error_)); + expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError); + }); it('should set the default viewport', async () => { const { puppeteer, defaultBrowserOptions } = getTestState(); const options = Object.assign({}, defaultBrowserOptions, {