Skip to content

Commit

Permalink
when this.stats is called, add optional chaining or check for exist…
Browse files Browse the repository at this point in the history
…ence (#6459)
  • Loading branch information
xta authored May 31, 2024
1 parent 1b7cb22 commit f379442
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils/xhr-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class XhrLoader implements Loader<LoaderContext> {
this.config = null;
this.context = null;
this.xhrSetup = null;
// @ts-ignore
this.stats = null;
}

abortInternal() {
Expand Down Expand Up @@ -100,15 +98,16 @@ class XhrLoader implements Loader<LoaderContext> {
if (xhrSetup) {
Promise.resolve()
.then(() => {
if (this.stats.aborted) return;
if (this.loader !== xhr || this.stats.aborted) return;
return xhrSetup(xhr, context.url);
})
.catch((error: Error) => {
if (this.loader !== xhr || this.stats.aborted) return;
xhr.open('GET', context.url, true);
return xhrSetup(xhr, context.url);
})
.then(() => {
if (this.stats.aborted) return;
if (this.loader !== xhr || this.stats.aborted) return;
this.openAndSendXhr(xhr, context, config);
})
.catch((error: Error) => {
Expand Down Expand Up @@ -263,7 +262,8 @@ class XhrLoader implements Loader<LoaderContext> {
}

loadtimeout() {
const retryConfig = this.config?.loadPolicy.timeoutRetry;
if (!this.config) return;
const retryConfig = this.config.loadPolicy.timeoutRetry;
const retryCount = this.stats.retry;
if (shouldRetry(retryConfig, retryCount, true)) {
this.retry(retryConfig);
Expand Down

0 comments on commit f379442

Please sign in to comment.