Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/server/__snapshots__/2_cdp_spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
19 changes: 17 additions & 2 deletions packages/server/__snapshots__/protocol_spec.ts.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
]
6 changes: 6 additions & 0 deletions packages/server/lib/browsers/protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion packages/server/lib/errors.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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)
Expand Down
15 changes: 12 additions & 3 deletions packages/server/test/unit/browsers/protocol_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
})
Expand All @@ -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.

Expand Down