diff --git a/lib/dispatcher/client-h2.js b/lib/dispatcher/client-h2.js index 00084738a1c..4a52effb1f3 100644 --- a/lib/dispatcher/client-h2.js +++ b/lib/dispatcher/client-h2.js @@ -242,11 +242,12 @@ function onHTTP2GoAway (code) { util.destroy(this[kSocket], err) // Fail head of pipeline. - const request = client[kQueue][client[kRunningIdx]] - client[kQueue][client[kRunningIdx]++] = null - util.errorRequest(client, request, err) - - client[kPendingIdx] = client[kRunningIdx] + if (client[kRunningIdx] < client[kQueue].length) { + const request = client[kQueue][client[kRunningIdx]] + client[kQueue][client[kRunningIdx]++] = null + util.errorRequest(client, request, err) + client[kPendingIdx] = client[kRunningIdx] + } assert(client[kRunning] === 0)