diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-12-06 05:29:29 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-12-13 06:32:55 +0100 |
commit | f96a86cac583675d10f601316c6ec4803bb851cc (patch) | |
tree | 6f1e8c520705f3e202fcbaee99ed197adfc1a064 /test | |
parent | cd71fc1545db30ca8589ddf1933167286308ad8f (diff) | |
download | node-new-f96a86cac583675d10f601316c6ec4803bb851cc.tar.gz |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-tls-transport-destroy-after-own-gc.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/parallel/test-tls-transport-destroy-after-own-gc.js b/test/parallel/test-tls-transport-destroy-after-own-gc.js new file mode 100644 index 0000000000..46f630982a --- /dev/null +++ b/test/parallel/test-tls-transport-destroy-after-own-gc.js @@ -0,0 +1,30 @@ +// 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(); + }); +}); |