summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-writewrap-leak.js
blob: 7035764cba5394b5f376d443c02b91be49170be9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'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(common.mustCall((c) => {
  c.destroy();
})).listen(0, common.mustCall(() => {
  const c = tls.connect({ port: server.address().port });
  c.on('error', () => {
    // Otherwise `.write()` callback won't be invoked.
    c._undestroy();
  });

  c.write('hello', common.mustCall((err) => {
    assert.strictEqual(err.code, 'ECANCELED');
    server.close();
  }));
}));