Skip to content

Commit 091238a

Browse files
leeightrvagg
authored andcommitted
http2: fix session[kSession] undefined issue
`finishSessionDestroy` session cleanup when already done. PR-URL: #24547 Fixes: #24546 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ouyang Yadong <oyydoibh@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent cd1aa2b commit 091238a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/internal/http2/core.js

+1
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,7 @@ class Http2Stream extends Duplex {
19891989
// attempt to gracefully close the session.
19901990
const state = this[kState];
19911991
if (this.headersSent &&
1992+
this[kSession] &&
19921993
this[kSession][kType] === NGHTTP2_SESSION_SERVER &&
19931994
!(state.flags & STREAM_FLAGS_HAS_TRAILERS) &&
19941995
!state.didRead &&
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
const h2 = require('http2');
7+
8+
const server = h2.createServer();
9+
server.listen(0, common.localhostIPv4, common.mustCall(() => {
10+
const afterConnect = common.mustCall((session) => {
11+
session.request({ ':method': 'POST' }).end(common.mustCall(() => {
12+
session.destroy();
13+
server.close();
14+
}));
15+
});
16+
17+
const port = server.address().port;
18+
const host = common.localhostIPv4;
19+
h2.connect('http://' + host + ':' + port, afterConnect);
20+
}));

0 commit comments

Comments
 (0)