mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
7f7a899fa5
On the 'tlsClientError' event, the `tlsSocket` instance is passed as `closed` status. Thus, users can't get information such as `remote address`, `remoteFamily`, and so on. This adds a flag to close a socket after emitting an `error` event. Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com PR-URL: https://github.com/nodejs/node/pull/44021 Fixes: https://github.com/nodejs/node/issues/43963 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
32 lines
930 B
JavaScript
32 lines
930 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const https = require('node:https');
|
|
const assert = require('node:assert');
|
|
|
|
const server = https.createServer();
|
|
|
|
server.on(
|
|
'tlsClientError',
|
|
common.mustCall((exception, tlsSocket) => {
|
|
assert.strictEqual(exception !== undefined, true);
|
|
assert.strictEqual(Object.keys(tlsSocket.address()).length !== 0, true);
|
|
assert.strictEqual(tlsSocket.localAddress !== undefined, true);
|
|
assert.strictEqual(tlsSocket.localPort !== undefined, true);
|
|
assert.strictEqual(tlsSocket.remoteAddress !== undefined, true);
|
|
assert.strictEqual(tlsSocket.remoteFamily !== undefined, true);
|
|
assert.strictEqual(tlsSocket.remotePort !== undefined, true);
|
|
}),
|
|
);
|
|
|
|
server.listen(0, () => {
|
|
const req = https.request({
|
|
hostname: '127.0.0.1',
|
|
port: server.address().port,
|
|
});
|
|
req.on(
|
|
'error',
|
|
common.mustCall(() => server.close()),
|
|
);
|
|
req.end();
|
|
});
|