mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
311e12b962
Previously destroy could be called multiple times causing inconsistent and hard to predict behavior. Furthermore, since the stream _destroy implementation can only be called once, the behavior of applying destroy multiple times becomes unclear. This changes so that only the first destroy() call is executed and any subsequent calls are noops. PR-URL: https://github.com/nodejs/node/pull/29197 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
34 lines
880 B
JavaScript
34 lines
880 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
const tls = require('tls');
|
|
|
|
const server = net.createServer((c) => {
|
|
c.end();
|
|
}).listen(common.mustCall(() => {
|
|
const port = server.address().port;
|
|
|
|
let errored = false;
|
|
tls.connect({
|
|
port: port,
|
|
localAddress: common.localhostIPv4
|
|
}, common.localhostIPv4)
|
|
.once('error', common.mustCall((e) => {
|
|
assert.strictEqual(e.code, 'ECONNRESET');
|
|
assert.strictEqual(e.path, undefined);
|
|
assert.strictEqual(e.host, undefined);
|
|
assert.strictEqual(e.port, port);
|
|
assert.strictEqual(e.localAddress, common.localhostIPv4);
|
|
server.close();
|
|
errored = true;
|
|
}))
|
|
.on('close', common.mustCall(() => {
|
|
assert.strictEqual(errored, true);
|
|
}));
|
|
}));
|