mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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: https://github.com/nodejs/node/pull/16753 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
2 files changed
+6
-3
No files matched your search
@@ -970,9 +970,8 @@ class Http2Session extends EventEmitter {
|
||||
|
||||
const state = stream[kState];
|
||||
if (state.rst) {
|
||||
// rst has already been called, do not call again,
|
||||
// skip straight to destroy
|
||||
stream.destroy();
|
||||
// rst has already been called by self or peer,
|
||||
// do not call again
|
||||
return;
|
||||
}
|
||||
state.rst = true;
|
||||
|
||||
@@ -21,6 +21,10 @@ server.on('listening', common.mustCall(() => {
|
||||
// make sure that destroy is called
|
||||
req._destroy = common.mustCall(req._destroy.bind(req));
|
||||
|
||||
// second call doesn't do anything
|
||||
assert.doesNotThrow(() => client.rstStream(req, 8));
|
||||
assert.strictEqual(req.rstCode, 0);
|
||||
|
||||
req.on('streamClosed', common.mustCall((code) => {
|
||||
assert.strictEqual(req.destroyed, true);
|
||||
assert.strictEqual(code, 0);
|
||||
|
||||
Reference in new issue
Block a user