mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-22 15:12:27 -05:00
Always use 127.0.0.1 instead of localhost for CDP (#5960)
* force ipv4 for CDP * update tests
This commit is contained in:
committed by
Jennifer Shehane
parent
efe83ca84c
commit
ddc86343a1
@@ -360,7 +360,10 @@ module.exports = {
|
||||
|
||||
return getRemoteDebuggingPort()
|
||||
.then((port) => {
|
||||
// force ipv4
|
||||
// https://github.com/cypress-io/cypress/issues/5912
|
||||
args.push(`--remote-debugging-port=${port}`)
|
||||
args.push('--remote-debugging-address=127.0.0.1')
|
||||
|
||||
return Promise.all([
|
||||
// ensure that we have a clean cache dir
|
||||
|
||||
@@ -47,16 +47,23 @@ const getWsTargetFor = (port) => {
|
||||
debug('Getting WS connection to CRI on port %d', port)
|
||||
la(is.port(port), 'expected port number', port)
|
||||
|
||||
return _connectAsync({ port })
|
||||
// force ipv4
|
||||
// https://github.com/cypress-io/cypress/issues/5912
|
||||
const connectOpts = {
|
||||
host: '127.0.0.1',
|
||||
port,
|
||||
}
|
||||
|
||||
return _connectAsync(connectOpts)
|
||||
.tapCatch((err) => {
|
||||
debug('failed to connect to CDP %o', { port, err })
|
||||
debug('failed to connect to CDP %o', { connectOpts, err })
|
||||
})
|
||||
.then(() => {
|
||||
debug('CRI.List on port %d', port)
|
||||
|
||||
// what happens if the next call throws an error?
|
||||
// it seems to leave the browser instance open
|
||||
return CRI.List({ port })
|
||||
return CRI.List(connectOpts)
|
||||
})
|
||||
.then((targets) => {
|
||||
debug('CRI List %o', { numTargets: targets.length, targets })
|
||||
|
||||
@@ -81,6 +81,7 @@ describe "lib/browsers/chrome", ->
|
||||
expect(args).to.deep.eq([
|
||||
"--headless"
|
||||
"--remote-debugging-port=50505"
|
||||
"--remote-debugging-address=127.0.0.1"
|
||||
"--user-data-dir=/profile/dir"
|
||||
"--disk-cache-dir=/profile/dir/CypressCache"
|
||||
])
|
||||
|
||||
@@ -76,7 +76,7 @@ describe('lib/browsers/protocol', function () {
|
||||
|
||||
const end = sinon.stub()
|
||||
|
||||
sinon.stub(CRI, 'List').withArgs({ port: 12345 }).resolves(targets)
|
||||
sinon.stub(CRI, 'List').withArgs({ host: '127.0.0.1', port: 12345 }).resolves(targets)
|
||||
sinon.stub(connect, 'createRetryingSocket').callsArgWith(1, null, { end })
|
||||
|
||||
const p = protocol.getWsTargetFor(12345)
|
||||
|
||||
Reference in New Issue
Block a user