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.

Backport-PR-URL: https://github.com/nodejs/node/pull/22850
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Ruben Bridgewater authored and Beth Griggs committed 2018-10-17 00:07:24 +01:00
1 parent 41dca9e851
commit 28a6e59bd3
1 file changed
+5 -2
+5 -2
View File
@@ -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'));
}
};
}