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
Promisify xhrSetup #5290
Promisify xhrSetup #5290
Conversation
.then(() => { | ||
return xhrSetup(xhr, context.url); | ||
}) | ||
.catch((error) => { | ||
xhr.open('GET', context.url, true); | ||
xhrSetup(xhr, context.url); | ||
} | ||
} | ||
if (!xhr.readyState) { | ||
xhr.open('GET', context.url, true); | ||
} | ||
return xhrSetup(xhr, context.url); | ||
}) | ||
.then(() => { | ||
this.openAndSendXhr(xhr, context, config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With async code we should check if abortInternal
has been called before continuing. Do we need an this.stats.aborted
check at the start of each async callback?
Something like:
.then(() => {
if (this.stats.aborted) return;
return xhrSetup(xhr, context.url);
.then(() => {
if (this.stats.aborted) return;
this.openAndSendXhr(xhr, context, config);
Otherwise if a loader is initialized and is immediately followed by a call to abort, with xhrSetup, the request would still be made.
Merged into master with
|
This PR will...
Promisify the xhrSetup. It's useful when we need to wait that xhrSetup is completed before continuing the process.
Why is this Pull Request needed?
I need to await xhrSetup. I think it could help some others.
Are there any points in the code the reviewer needs to double check?
Resolves issues:
No issue
Checklist