From 9b8abb860b08f2bc1f7397a7c40b72d28d4bd1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E9=B8=BF=E9=A3=9E?= Date: Sun, 24 Nov 2024 20:52:03 +0800 Subject: [PATCH] fix: Fixed the issue that there is no running request when http2 goaway (#3875) --- 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)