Skip to content

Commit

Permalink
http2: fix ping callback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
BridgeAR authored and kjin committed Aug 23, 2018
1 parent eb18c26 commit a69c76b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ function onStreamClose(code) {
if (!stream.closed)
closeStream(stream, code, false);

if (this[kState].fd !== undefined)
tryClose(this[kState].fd);
if (stream[kState].fd !== undefined)
tryClose(stream[kState].fd);

// Defer destroy we actually emit end.
if (stream._readableState.endEmitted || code !== NGHTTP2_NO_ERROR) {
Expand Down Expand Up @@ -662,8 +662,11 @@ const proxySocketHandler = {
// data received on the PING acknowlegement.
function pingCallback(cb) {
return function pingCallback(ack, duration, payload) {
const err = ack ? null : new errors.Error('ERR_HTTP2_PING_CANCEL');
cb(err, duration, payload);
if (ack) {
cb(null, duration, payload);
} else {
cb(new errors.Error('ERR_HTTP2_PING_CANCEL'));
}
};
}

Expand Down

0 comments on commit a69c76b

Please sign in to comment.