From 13da1b4a8dae3f75225d7ac512107929834eed2f Mon Sep 17 00:00:00 2001 From: ShenHongFei Date: Sun, 24 Nov 2024 12:30:10 +0800 Subject: [PATCH] Fixed the issue that there is no running request when http2 goaway --- lib/dispatcher/client-h2.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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)