http2: guard against destroyed session, timeouts · nodejs/node@afa72df · GitHub
Skip to content

Commit afa72df

Browse files
jasnellMylesBorins
authored andcommitted
http2: guard against destroyed session, timeouts
Guard against destroyed session in timeouts and goaway event. Improve timeout handling a bit. PR-URL: #15106 Fixes: #14964 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent f6c5188 commit afa72df

3 files changed

Lines changed: 38 additions & 7 deletions

File tree

lib/internal/http2/core.js

Lines changed: 10 additions & 5 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Flags: --expose-http2
2+
'use strict';
3+
4+
const common = require('../common');
5+
if (!common.hasCrypto)
6+
common.skip('missing crypto');
7+
const http2 = require('http2');
8+
9+
const server = http2.createServer();
10+
server.on('stream', common.mustCall((stream) => {
11+
stream.on('error', common.mustCall());
12+
stream.session.shutdown();
13+
}));
14+
15+
server.listen(0, common.mustCall(() => {
16+
const client = http2.connect(`http://localhost:${server.address().port}`);
17+
18+
client.on('goaway', common.mustCall(() => {
19+
// We ought to be able to destroy the client in here without an error
20+
server.close();
21+
client.destroy();
22+
}));
23+
24+
client.request();
25+
}));

test/parallel/test-http2-server-shutdown-before-respond.js

Lines changed: 3 additions & 2 deletions

0 commit comments

Comments
 (0)