diff --git a/lib/dispatcher/client-h2.js b/lib/dispatcher/client-h2.js index 9274238cc0f..fa19f0e7c9f 100644 --- a/lib/dispatcher/client-h2.js +++ b/lib/dispatcher/client-h2.js @@ -203,11 +203,12 @@ function onHttp2SessionGoAway (errorCode) { 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)