From 2b399b61031a1051d2c5fef305fd8f45ab17a86e Mon Sep 17 00:00:00 2001 From: leonsabr Date: Tue, 27 Dec 2016 18:27:52 +0300 Subject: [PATCH] fix: prevent endless loop when suitesPerSession is set to infinity Once all suites have run, runner should perform retries in a new browser session. If parameter suitesPerSession is set to infinity (which is a default value), getBrowser method fails to quit previous session because force quit is missing in the freeBrowser method call, and getBrowser is called again recursively. --- lib/runner/browser-runner/browser-agent.js | 2 +- test/unit/runner/browser-runner/browser-agent.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/runner/browser-runner/browser-agent.js b/lib/runner/browser-runner/browser-agent.js index b16572786..81a662b77 100644 --- a/lib/runner/browser-runner/browser-agent.js +++ b/lib/runner/browser-runner/browser-agent.js @@ -17,7 +17,7 @@ module.exports = class BrowserAgent { return this._pool.getBrowser(this.browserId) .then((browser) => { if (_.includes(this._sessions, browser.sessionId)) { - return this.freeBrowser(browser).then(() => this.getBrowser()); + return this.freeBrowser(browser, {force: true}).then(() => this.getBrowser()); } this._sessions.push(browser.sessionId); diff --git a/test/unit/runner/browser-runner/browser-agent.js b/test/unit/runner/browser-runner/browser-agent.js index ab6e6f628..22039aef5 100644 --- a/test/unit/runner/browser-runner/browser-agent.js +++ b/test/unit/runner/browser-runner/browser-agent.js @@ -48,7 +48,7 @@ describe('runner/browser-runner/browser-agent', () => { .then((bro) => { assert.equal(bro, otherBro); assert.calledTwice(browserPool.getBrowser); - assert.calledWith(browserPool.freeBrowser, someBro); + assert.calledWith(browserPool.freeBrowser, someBro, {force: true}); }); });