[Backport 7.x] Show socket local/remote address in case of ECONNRESET (#1556)

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2021-09-22 10:06:50 +02:00
committed by delvedor
parent 3a3530e000
commit 5a88a2f398
2 changed files with 30 additions and 1 deletions

View File

@ -1084,3 +1084,25 @@ test('getIssuerCertificate detects invalid/malformed certificates', t => {
}
t.equal(getIssuerCertificate(socket), null)
})
test('Should show local/remote socket address in case of ECONNRESET', t => {
t.plan(2)
function handler (req, res) {
res.destroy()
}
buildServer(handler, ({ port }, server) => {
const connection = new Connection({
url: new URL(`http://localhost:${port}`)
})
connection.request({
path: '/hello',
method: 'GET'
}, (err, res) => {
t.ok(err instanceof ConnectionError)
t.match(err.message, /socket\shang\sup\s-\sLocal:\s127.0.0.1:\d+,\sRemote:\s127.0.0.1:\d+/)
server.stop()
})
})
})