Skip to content

Commit fcac397

Browse files
MalvitusfredericOfTestfabrikmjhenkes
authored
feat: Added configuration parameter that controls the amount of connection attempts to the browser (#25848)
* feat: Added configuration parameter that controls the amount of connection attempts to the browser * Revert "feat: Added configuration parameter that controls the amount of connection attempts to the browser" This reverts commit 4fd816a. * feat: Added configuration parameter that controls the amount of connection attempts to the browser * feat: Adjusted naming to match other env Variables * Fix Off by one error in firefox utils Co-authored-by: Matt Henkes <[email protected]> * Updated Changelog * Update cli/CHANGELOG.md * Update cli/CHANGELOG.md * Update cli/CHANGELOG.md * Trying to fix unit test --------- Co-authored-by: fburgard <[email protected]> Co-authored-by: Matt Henkes <[email protected]>
1 parent fbc5527 commit fcac397

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

cli/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
2-
## 12.7.1
2+
## 12.8.0
33

44
_Released 03/14/2023 (PENDING)_
55

6+
**Features:**
7+
8+
- It is now possible to control the number of connection attempts to the browser using the CYPRESS_CONNECT_RETRY_THRESHOLD Environment Variable. Learn more [here](https://docs.cypress.io/guides/references/advanced-installation#Environment-variables). Addressed in [#25848](https://github.com/cypress-io/cypress/pull/25848).
9+
610
**Dependency Updates:**
711

812
- Upgraded [`mocha-junit-reporter`](https://github.com/michaelleeallen/mocha-junit-reporter) from `2.1.0` to `2.2.0` to be able to use [new placeholders](https://github.com/michaelleeallen/mocha-junit-reporter/pull/163) such as `[suiteFilename]` or `[suiteName]` when defining the test report name. Addressed in [#25922](https://github.com/cypress-io/cypress/pull/25922).

packages/errors/src/errors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,8 @@ export const AllCypressErrors = {
10631063
10641064
${fmt.stackTrace(arg1)}`
10651065
},
1066-
CDP_RETRYING_CONNECTION: (attempt: string | number, browserName: string) => {
1067-
return errTemplate`Still waiting to connect to ${fmt.off(_.capitalize(browserName))}, retrying in 1 second ${fmt.meta(`(attempt ${attempt}/62)`)}`
1066+
CDP_RETRYING_CONNECTION: (attempt: string | number, browserName: string, connectRetryThreshold: number) => {
1067+
return errTemplate`Still waiting to connect to ${fmt.off(_.capitalize(browserName))}, retrying in 1 second ${fmt.meta(`(attempt ${attempt}/${connectRetryThreshold})`)}`
10681068
},
10691069
UNEXPECTED_BEFORE_BROWSER_LAUNCH_PROPERTIES: (arg1: string[], arg2: string[]) => {
10701070
return errTemplate`\

packages/errors/test/unit/visualSnapshotErrors_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ describe('visual error templates', () => {
10091009
},
10101010
CDP_RETRYING_CONNECTION: () => {
10111011
return {
1012-
default: [1, 'chrome'],
1012+
default: [1, 'chrome', 62],
10131013
}
10141014
},
10151015
UNEXPECTED_BEFORE_BROWSER_LAUNCH_PROPERTIES: () => {

packages/server/lib/browsers/firefox-util.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const getTabId = (tab) => {
3333
}
3434

3535
const getDelayMsForRetry = (i) => {
36+
let maxRetries = Number.parseInt(process.env.CYPRESS_CONNECT_RETRY_THRESHOLD ? process.env.CYPRESS_CONNECT_RETRY_THRESHOLD : '62')
37+
3638
if (i < 10) {
3739
return 100
3840
}
@@ -41,7 +43,7 @@ const getDelayMsForRetry = (i) => {
4143
return 500
4244
}
4345

44-
if (i < 63) {
46+
if (i <= maxRetries) {
4547
return 1000
4648
}
4749

packages/server/lib/browsers/protocol.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import utils from './utils'
55
const errors = require('../errors')
66

77
export function _getDelayMsForRetry (i, browserName) {
8+
let maxRetries = Number.parseInt(process.env.CYPRESS_CONNECT_RETRY_THRESHOLD ? process.env.CYPRESS_CONNECT_RETRY_THRESHOLD : '62')
9+
810
if (i < 10) {
911
return 100
1012
}
@@ -13,8 +15,8 @@ export function _getDelayMsForRetry (i, browserName) {
1315
return 500
1416
}
1517

16-
if (i < 63) { // after 5 seconds, begin logging and retrying
17-
errors.warning('CDP_RETRYING_CONNECTION', i, browserName)
18+
if (i <= maxRetries) { // after 5 seconds, begin logging and retrying
19+
errors.warning('CDP_RETRYING_CONNECTION', i, browserName, maxRetries)
1820

1921
return 1000
2022
}

0 commit comments

Comments
 (0)