summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-stream-destroy-event-order.js
blob: e2732830efbd8af8a879c41044955c74cf60e940 (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
25
26
27
28
29
'use strict';

const common = require('../common');
if (!common.hasCrypto)
  common.skip('missing crypto');
const http2 = require('http2');

let client;
let req;
const server = http2.createServer();
server.on('stream', common.mustCall((stream) => {
  stream.on('close', common.mustCall(() => {
    stream.on('error', common.mustCall(() => {
      server.close();
    }));
  }));

  req.close(2);
}));
server.listen(0, common.mustCall(() => {
  client = http2.connect(`http://localhost:${server.address().port}`);
  req = client.request();
  req.resume();
  req.on('close', common.mustCall(() => {
    req.on('error', common.mustCall(() => {
      client.close();
    }));
  }));
}));