From 28a6e59bd31e91cfa8517e2ed8e80ab19fdfd2bd Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 26 Apr 2018 02:13:39 +0200 Subject: [PATCH] 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 Reviewed-By: Matteo Collina Reviewed-By: Trivikram Kamat --- lib/internal/http2/core.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 00272651d604cb..5fa8e87ddbd04b 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -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')); + } }; }