node/test/parallel/test-http2-server-timeout.js
James M Snell 953458f645 http2: fix socketOnTimeout and a segfault
Fixes: https://github.com/nodejs/http2/issues/179

Was fixing issue #179 and encountered a segault that was
happening somewhat randomly on session destruction. Both
should be fixed

PR-URL: https://github.com/nodejs/node/pull/14239
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-08-04 12:56:39 -07:00

28 lines
711 B
JavaScript
Executable File

// Flags: --expose-http2
'use strict';
const common = require('../common');
const http2 = require('http2');
const server = http2.createServer();
server.setTimeout(common.platformTimeout(1));
const onServerTimeout = common.mustCall((session) => {
session.destroy();
server.removeListener('timeout', onServerTimeout);
});
server.on('stream', common.mustNotCall());
server.on('timeout', onServerTimeout);
server.listen(0, common.mustCall(() => {
const url = `http://localhost:${server.address().port}`;
const client = http2.connect(url);
client.on('close', common.mustCall(() => {
const client2 = http2.connect(url);
client2.on('close', common.mustCall(() => server.close()));
}));
}));