1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6
7const http2 = require('http2');
8
9const server = http2.createServer();
10
11server.listen(0, () => {
12  const client = http2.connect(`http://localhost:${server.address().port}`);
13  client.on('close', common.mustCall(() => {
14    server.close();
15  }));
16
17  // The client.close() is executed before the socket is able to make request
18  const stream = client.request();
19  stream.on('error', common.expectsError({ code: 'ERR_HTTP2_GOAWAY_SESSION' }));
20
21  setImmediate(() => client.close());
22});
23