0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/parallel/test-tls-transport-destroy-after-own-gc.js
Anna Henningsen f96a86cac5
tls: unconsume stream on destroy
When the TLS stream is destroyed for whatever reason,
we should unset all callbacks on the underlying transport
stream.

PR-URL: https://github.com/nodejs/node/pull/17478
Fixes: https://github.com/nodejs/node/issues/17475
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-12-13 06:32:55 +01:00

31 lines
753 B
JavaScript

// Flags: --expose-gc
'use strict';
// Regression test for https://github.com/nodejs/node/issues/17475
// Unfortunately, this tests only "works" reliably when checked with valgrind or
// a similar tool.
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const { TLSSocket } = require('tls');
const makeDuplexPair = require('../common/duplexpair');
let { clientSide } = makeDuplexPair();
let clientTLS = new TLSSocket(clientSide, { isServer: false });
// eslint-disable-next-line no-unused-vars
let clientTLSHandle = clientTLS._handle;
setImmediate(() => {
clientTLS = null;
global.gc();
clientTLSHandle = null;
global.gc();
setImmediate(() => {
clientSide = null;
global.gc();
});
});