diff --git a/packages/server/__snapshots__/2_cdp_spec.ts.js b/packages/server/__snapshots__/2_cdp_spec.ts.js index bae964621b5..29bcc77870c 100644 --- a/packages/server/__snapshots__/2_cdp_spec.ts.js +++ b/packages/server/__snapshots__/2_cdp_spec.ts.js @@ -15,7 +15,22 @@ exports['e2e cdp / fails when remote debugging port cannot be connected to'] = ` ──────────────────────────────────────────────────────────────────────────────────────────────────── Running: spec.ts (1 of 1) -Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 5 seconds. +Failed to connect to Chrome, retrying in 1 second (attempt 18/32) +Failed to connect to Chrome, retrying in 1 second (attempt 19/32) +Failed to connect to Chrome, retrying in 1 second (attempt 20/32) +Failed to connect to Chrome, retrying in 1 second (attempt 21/32) +Failed to connect to Chrome, retrying in 1 second (attempt 22/32) +Failed to connect to Chrome, retrying in 1 second (attempt 23/32) +Failed to connect to Chrome, retrying in 1 second (attempt 24/32) +Failed to connect to Chrome, retrying in 1 second (attempt 25/32) +Failed to connect to Chrome, retrying in 1 second (attempt 26/32) +Failed to connect to Chrome, retrying in 1 second (attempt 27/32) +Failed to connect to Chrome, retrying in 1 second (attempt 28/32) +Failed to connect to Chrome, retrying in 1 second (attempt 29/32) +Failed to connect to Chrome, retrying in 1 second (attempt 30/32) +Failed to connect to Chrome, retrying in 1 second (attempt 31/32) +Failed to connect to Chrome, retrying in 1 second (attempt 32/32) +Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 20 seconds. This usually indicates there was a problem opening the Chrome browser. diff --git a/packages/server/__snapshots__/protocol_spec.ts.js b/packages/server/__snapshots__/protocol_spec.ts.js index c970d204ca9..313c2312dd6 100644 --- a/packages/server/__snapshots__/protocol_spec.ts.js +++ b/packages/server/__snapshots__/protocol_spec.ts.js @@ -1,4 +1,4 @@ -exports['lib/browsers/protocol ._getDelayMsForRetry retries as expected for up to 5 seconds 1'] = [ +exports['lib/browsers/protocol ._getDelayMsForRetry retries as expected for up to 20 seconds 1'] = [ 100, 100, 100, @@ -16,5 +16,20 @@ exports['lib/browsers/protocol ._getDelayMsForRetry retries as expected for up t 500, 500, 500, - 500 + 500, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000, + 1000 ] diff --git a/packages/server/lib/browsers/protocol.js b/packages/server/lib/browsers/protocol.js index ae5cb7aa410..7785566d86f 100644 --- a/packages/server/lib/browsers/protocol.js +++ b/packages/server/lib/browsers/protocol.js @@ -15,6 +15,12 @@ function _getDelayMsForRetry (i) { if (i < 18) { return 500 } + + if (i < 33) { // after 5 seconds, begin logging and retrying + errors.warning('CDP_RETRYING_CONNECTION', i) + + return 1000 + } } function _connectAsync (opts) { diff --git a/packages/server/lib/errors.coffee b/packages/server/lib/errors.coffee index 653c40ef526..ca7f54ff99c 100644 --- a/packages/server/lib/errors.coffee +++ b/packages/server/lib/errors.coffee @@ -848,7 +848,7 @@ getMsgByType = (type, arg1 = {}, arg2) -> """ when "CDP_COULD_NOT_CONNECT" """ - Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 5 seconds. + Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 20 seconds. This usually indicates there was a problem opening the Chrome browser. @@ -858,6 +858,10 @@ getMsgByType = (type, arg1 = {}, arg2) -> #{arg2.stack} """ + when "CDP_RETRYING_CONNECTION" + """ + Failed to connect to Chrome, retrying in 1 second (attempt #{chalk.yellow(arg1)}/32) + """ get = (type, arg1, arg2) -> msg = getMsgByType(type, arg1, arg2) diff --git a/packages/server/test/unit/browsers/protocol_spec.ts b/packages/server/test/unit/browsers/protocol_spec.ts index 4d5bc5eaf9e..03e21b370eb 100644 --- a/packages/server/test/unit/browsers/protocol_spec.ts +++ b/packages/server/test/unit/browsers/protocol_spec.ts @@ -9,11 +9,14 @@ import humanInterval from 'human-interval' import protocol from '../../../lib/browsers/protocol' import sinon from 'sinon' import snapshot from 'snap-shot-it' +import stripAnsi from 'strip-ansi' import { stripIndents } from 'common-tags' describe('lib/browsers/protocol', function () { context('._getDelayMsForRetry', function () { - it('retries as expected for up to 5 seconds', function () { + it('retries as expected for up to 20 seconds', function () { + const log = sinon.spy(console, 'log') + let delays = [] let delay: number let i = 0 @@ -23,7 +26,13 @@ describe('lib/browsers/protocol', function () { i++ } - expect(_.sum(delays)).to.eq(humanInterval('5 seconds')) + expect(_.sum(delays)).to.eq(humanInterval('20 seconds')) + + log.getCalls().forEach((log, i) => { + const line = stripAnsi(log.args[0]) + + expect(line).to.include(`Failed to connect to Chrome, retrying in 1 second (attempt ${i + 18}/32)`) + }) snapshot(delays) }) @@ -37,7 +46,7 @@ describe('lib/browsers/protocol', function () { const p = protocol.getWsTargetFor(12345) const expectedError = stripIndents` - Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 5 seconds. + Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 20 seconds. This usually indicates there was a problem opening the Chrome browser.