• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6const http2 = require('http2');
7
8// Regression test for https://github.com/nodejs/node/issues/29457:
9// HTTP/2 stream event listeners can be added and removed after the
10// session has been destroyed.
11
12const server = http2.createServer((req, res) => {
13  res.end('Hi!\n');
14});
15
16server.listen(0, common.mustCall(() => {
17  const client = http2.connect(`http://localhost:${server.address().port}`);
18  const headers = { ':path': '/' };
19  const req = client.request(headers);
20
21  req.on('close', common.mustCall(() => {
22    req.removeAllListeners();
23    req.on('priority', common.mustNotCall());
24    server.close();
25  }));
26
27  req.on('priority', common.mustNotCall());
28  req.on('error', common.mustCall());
29
30  client.destroy();
31}));
32