summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-goaway-delayed-request.js
blob: 7afadbe80186ee797aef867a18caa8531b457d80 (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');

const http2 = require('http2');

const server = http2.createServer();

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

  // The client.close() is executed before the socket is able to make request
  const stream = client.request();
  stream.on('error', common.expectsError({ code: 'ERR_HTTP2_GOAWAY_SESSION' }));

  setImmediate(() => client.close());
});