mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-20 06:04:08 -05:00
test: only test https-proxy socket close if socket is not already closed in client disconnect test (#28819)
This commit is contained in:
@@ -320,29 +320,32 @@ describe('Proxy', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('closes outgoing connections when client disconnects', function () {
|
||||
it('closes outgoing connections when client disconnects', async function () {
|
||||
this.sandbox.spy(net, 'connect')
|
||||
|
||||
return request({
|
||||
await request({
|
||||
strictSSL: false,
|
||||
url: 'https://localhost:8444/replace',
|
||||
proxy: 'http://localhost:3333',
|
||||
resolveWithFullResponse: true,
|
||||
forever: false,
|
||||
})
|
||||
.then(() => {
|
||||
// ensure the outgoing socket created for this connection was destroyed
|
||||
expect(net.connect).calledOnce
|
||||
const socket = net.connect.getCalls()[0].returnValue
|
||||
|
||||
// ensure the outgoing socket created for this connection was destroyed
|
||||
expect(net.connect).calledOnce
|
||||
const socket = net.connect.getCalls()[0].returnValue
|
||||
|
||||
// sometimes the close event happens before we can attach the listener,
|
||||
// causing this test to flake
|
||||
if (!socket.destroyed || !socket.readyState === 'closed') {
|
||||
return new Promise((resolve) => {
|
||||
return socket.on('close', () => {
|
||||
socket.on('close', () => {
|
||||
expect(socket.destroyed).to.be.true
|
||||
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// https://github.com/cypress-io/cypress/issues/4257
|
||||
|
||||
Reference in New Issue
Block a user