Skip to content

Commit 810edb8

Browse files
committed
test: http2 rstStream duplicate call
This commit fixes an issue with rstStream() which checked incorrect value of rst. It also adds a test case for this fix Refs: #14985
1 parent 411695e commit 810edb8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/internal/http2/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ class Http2Session extends EventEmitter {
925925
'number');
926926
}
927927

928-
if (this[kState].rst) {
928+
if (stream[kState].rst) {
929929
// rst has already been called, do not call again,
930930
// skip straight to destroy
931931
stream.destroy();

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ server.on('listening', common.mustCall(() => {
1515
const client = h2.connect(`http://localhost:${server.address().port}`);
1616

1717
const req = client.request({ ':path': '/' });
18+
// make sure that destroy is called twice
19+
req._destroy = common.mustCall(req._destroy.bind(req), 2);
20+
1821
client.rstStream(req, 0);
22+
// redundant call to rstStream with new code
23+
client.rstStream(req, 1);
24+
// confirm that rstCode is from the first call to rstStream
1925
assert.strictEqual(req.rstCode, 0);
2026

21-
// make sure that destroy is called
22-
req._destroy = common.mustCall(req._destroy.bind(req));
23-
2427
req.on('streamClosed', common.mustCall((code) => {
2528
assert.strictEqual(req.destroyed, true);
2629
assert.strictEqual(code, 0);

0 commit comments

Comments
 (0)