Files
cypress/packages/server/lib/browsers/protocol.ts
Malvitus fcac397fe8 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 4fd816a7fe.

* 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 <mjhenkes@gmail.com>

* Updated Changelog

* Update cli/CHANGELOG.md

* Update cli/CHANGELOG.md

* Update cli/CHANGELOG.md

* Trying to fix unit test

---------

Co-authored-by: fburgard <fburgard@testfabrik.com>
Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
2023-03-02 15:56:37 -06:00

42 lines
1013 B
TypeScript

import { connect } from '@packages/network'
import Bluebird from 'bluebird'
import type { Socket } from 'net'
import utils from './utils'
const errors = require('../errors')
export function _getDelayMsForRetry (i, browserName) {
let maxRetries = Number.parseInt(process.env.CYPRESS_CONNECT_RETRY_THRESHOLD ? process.env.CYPRESS_CONNECT_RETRY_THRESHOLD : '62')
if (i < 10) {
return 100
}
if (i < 18) {
return 500
}
if (i <= maxRetries) { // after 5 seconds, begin logging and retrying
errors.warning('CDP_RETRYING_CONNECTION', i, browserName, maxRetries)
return 1000
}
return
}
export function _connectAsync (opts) {
return Bluebird.fromCallback((cb) => {
connect.createRetryingSocket(opts, cb)
})
.then((sock) => {
// can be closed, just needed to test the connection
(sock as Socket).end()
})
}
export async function getRemoteDebuggingPort () {
const port = Number(process.env.CYPRESS_REMOTE_DEBUGGING_PORT) || await utils.getPort()
return port
}