Skip to content

Commit 2b25ad1

Browse files
apapirovskiMylesBorins
authored andcommitted
http2: simplify subsequent rstStream calls
Do not call destroy each time rstStream is called since the first call (or receipt of rst frame) will always trigger destroy. Expand existing test for this behaviour. PR-URL: #16753 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ba12784 commit 2b25ad1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/internal/http2/core.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,8 @@ class Http2Session extends EventEmitter {
972972

973973
const state = stream[kState];
974974
if (state.rst) {
975-
// rst has already been called, do not call again,
976-
// skip straight to destroy
977-
stream.destroy();
975+
// rst has already been called by self or peer,
976+
// do not call again
978977
return;
979978
}
980979
state.rst = true;

test/parallel/test-http2-client-rststream-before-connect.js

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ server.on('listening', common.mustCall(() => {
2121
// make sure that destroy is called
2222
req._destroy = common.mustCall(req._destroy.bind(req));
2323

24+
// second call doesn't do anything
25+
assert.doesNotThrow(() => client.rstStream(req, 8));
26+
assert.strictEqual(req.rstCode, 0);
27+
2428
req.on('streamClosed', common.mustCall((code) => {
2529
assert.strictEqual(req.destroyed, true);
2630
assert.strictEqual(code, 0);

0 commit comments

Comments
 (0)