From 2aed85bb1313db9c29561fccb68ea609bec14188 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 10 Nov 2021 14:59:32 +0000 Subject: [PATCH] Remove XHR from pending JS on exception --- tests/behat/app_behat_runtime.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/behat/app_behat_runtime.js b/tests/behat/app_behat_runtime.js index 0584a4eb3..831c354df 100644 --- a/tests/behat/app_behat_runtime.js +++ b/tests/behat/app_behat_runtime.js @@ -98,15 +98,20 @@ var index = requestIndex++; var key = 'httprequest-' + index; - // Add to the list of pending requests. - addPending(key); + try { + // Add to the list of pending requests. + addPending(key); - // Detect when it finishes and remove it from the list. - this.addEventListener('loadend', function() { + // Detect when it finishes and remove it from the list. + this.addEventListener('loadend', function() { + removePending(key); + }); + + return realOpen.apply(this, arguments); + } catch (e) { removePending(key); - }); - - return realOpen.apply(this, arguments); + throw e; + } }; var waitingBlocked = false;