Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when this.stats is called, add optional chaining or check for existence #6459

Merged
merged 8 commits into from
May 31, 2024
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
Loading