summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-stream-destroy-event-order.js
blob: 88e4a99f99eee32a3f980a956abb18aa2aec6419 (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('error', common.mustCall(() => {
    stream.on('close', 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('error', common.mustCall(() => {
    req.on('close', common.mustCall(() => {
      client.close();
    }));
  }));
}));