From 6066cc9cfa7887453f7b5473ae8f545617314dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr?= <8machy@seznam.cz> Date: Sun, 14 Jul 2024 11:02:35 +0200 Subject: [PATCH] Set abortNavigationRequestController to undefined after the request finishes. --- packages/signalizejs/src/modules/spa.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/signalizejs/src/modules/spa.js b/packages/signalizejs/src/modules/spa.js index a60f20a..625886b 100755 --- a/packages/signalizejs/src/modules/spa.js +++ b/packages/signalizejs/src/modules/spa.js @@ -21,8 +21,8 @@ export default async ({ params, resolve, root }, config) => { /** @type {import('../../types/modules/spa').HistoryState|undefined} */ let currentState; - /** @type {AbortController} */ - let abortNavigationController; + /** @type {AbortController|undefined} */ + let abortNavigationRequestController; const spaVersion = null; const host = window.location.host; /** @type {import('../../types/modules/spa').ResponseCache} */ @@ -87,11 +87,11 @@ export default async ({ params, resolve, root }, config) => { error: null }; - if (abortNavigationController !== undefined) { - abortNavigationController.abort(); + if (abortNavigationRequestController !== undefined) { + abortNavigationRequestController.abort(); } - abortNavigationController = new AbortController(); + abortNavigationRequestController = new AbortController(); const { stateAction = defaultStateAction } = data; const url = data.url instanceof URL ? data.url : createUrl(data.url); @@ -120,11 +120,12 @@ export default async ({ params, resolve, root }, config) => { dispatch('spa:request:start', { ...dispatchEventData }); navigationResponse = await ajax(urlString, { - signal: abortNavigationController.signal, + signal: abortNavigationRequestController.signal, headers: { Accept: 'text/html, application/xhtml+xml' } }); + abortNavigationRequestController = undefined; const requestIsWithoutErroor = navigationResponse.error === null; if (requestIsWithoutErroor) {