Skip to content

Commit a69c76b

Browse files
BridgeARkjin
authored andcommitted
http2: fix ping callback
In case there was no ack, the callback would have returned more than the error as return value. This makes sure that is not the case anymore. PR-URL: nodejs#20311 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent eb18c26 commit a69c76b

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

lib/internal/http2/core.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ function onStreamClose(code) {
285285
if (!stream.closed)
286286
closeStream(stream, code, false);
287287

288-
if (this[kState].fd !== undefined)
289-
tryClose(this[kState].fd);
288+
if (stream[kState].fd !== undefined)
289+
tryClose(stream[kState].fd);
290290

291291
// Defer destroy we actually emit end.
292292
if (stream._readableState.endEmitted || code !== NGHTTP2_NO_ERROR) {
@@ -662,8 +662,11 @@ const proxySocketHandler = {
662662
// data received on the PING acknowlegement.
663663
function pingCallback(cb) {
664664
return function pingCallback(ack, duration, payload) {
665-
const err = ack ? null : new errors.Error('ERR_HTTP2_PING_CANCEL');
666-
cb(err, duration, payload);
665+
if (ack) {
666+
cb(null, duration, payload);
667+
} else {
668+
cb(new errors.Error('ERR_HTTP2_PING_CANCEL'));
669+
}
667670
};
668671
}
669672

0 commit comments

Comments
 (0)