• 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
8function testServerTimeout(setTimeoutFn) {
9  const server = http2.createServer();
10  setTimeoutFn(server);
11
12  const onServerTimeout = common.mustCall((session) => {
13    session.close();
14  });
15
16  server.on('stream', common.mustNotCall());
17  server.once('timeout', onServerTimeout);
18
19  server.listen(0, common.mustCall(() => {
20    const url = `http://localhost:${server.address().port}`;
21    const client = http2.connect(url);
22    client.on('close', common.mustCall(() => {
23      const client2 = http2.connect(url);
24      client2.on('close', common.mustCall(() => server.close()));
25    }));
26  }));
27}
28
29const timeout = common.platformTimeout(50);
30testServerTimeout((server) => server.setTimeout(timeout));
31testServerTimeout((server) => server.timeout = timeout);
32