diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index a6dbd626ec882f..19790ad4e6ff39 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -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; diff --git a/test/parallel/test-http2-client-rststream-before-connect.js b/test/parallel/test-http2-client-rststream-before-connect.js index 073b2d4837d2d2..3c4ac3b34d86ad 100644 --- a/test/parallel/test-http2-client-rststream-before-connect.js +++ b/test/parallel/test-http2-client-rststream-before-connect.js @@ -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);