From 09e626e8ab7924f0490de6eb874840cbe2b5fa90 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Wed, 3 May 2023 08:51:55 +0100 Subject: [PATCH] Further fixes to cancelling outstanding HTTP requests --- core/modules/utils/dom/http.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/modules/utils/dom/http.js b/core/modules/utils/dom/http.js index 9306e21fd..ba4b3d2a1 100644 --- a/core/modules/utils/dom/http.js +++ b/core/modules/utils/dom/http.js @@ -65,9 +65,11 @@ HttpClient.prototype.initiateHttpRequest = function(options) { HttpClient.prototype.cancelAllHttpRequests = function() { var self = this; - for(var t=this.requests.length - 1; t--; t>=0) { - var requestInfo = this.requests[t]; - requestInfo.request.cancel(); + if(this.requests.length > 0) { + for(var t=this.requests.length - 1; t--; t>=0) { + var requestInfo = this.requests[t]; + requestInfo.request.cancel(); + } } this.requests = []; this.updateRequestTracker();