summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-tlswrap-segfault-2.js
blob: d4f3b12b99fdd516a0c42cbda7b2b8189a7f21be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';
const common = require('../common');
if (!common.hasCrypto)
  common.skip('missing crypto');

// This test ensures that Node.js doesn't incur a segfault while
// adding session or keylog listeners after destroy.
// https://github.com/nodejs/node/issues/38133
// https://github.com/nodejs/node/issues/38135

const tls = require('tls');
const tlsSocketKeyLog = tls.connect('cause-error');
tlsSocketKeyLog.on('error', common.mustCall());
tlsSocketKeyLog.on('close', common.mustCall(() => {
  tlsSocketKeyLog.on('keylog', common.mustNotCall());
}));

const tlsSocketSession = tls.connect('cause-error-2');
tlsSocketSession.on('error', common.mustCall());
tlsSocketSession.on('close', common.mustCall(() => {
  tlsSocketSession.on('session', common.mustNotCall());
}));