From 6a72b9998e6541bf0f0427e44c8669bf86868792 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) (cherry picked from commit 9b8abb860b08f2bc1f7397a7c40b72d28d4bd1c9) --- 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 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)