Skip to content

Commit

Permalink
Set abortNavigationRequestController to undefined after the request f…
Browse files Browse the repository at this point in the history
…inishes.
  • Loading branch information
Machy8 committed Jul 14, 2024
1 parent efac627 commit 6066cc9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/signalizejs/src/modules/spa.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} */
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6066cc9

Please sign in to comment.