-
Notifications
You must be signed in to change notification settings - Fork 611
Open
Description
In 2021 axios added the following change to onreadystatechange axios/axios#3688 which replaces onloadend instead of onreadystatechange on the axios instance:
if ('onloadend' in request) {
// Use onloadend if available
request.onloadend = onloadend;
} else {
// Listen for ready state to emulate onloadend
request.onreadystatechange = function handleLoad() {
...
}
this causes the MiniProfiler hooks for axios to stop working because onreadystatechange is no longer available as a hook
| if (this.onreadystatechange) { |
this.onreadystatechange will always be null for axios:
if ((window.angular || window.axios || window.xhr) && typeof (XMLHttpRequest) !== 'undefined') {
const oldSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function sendReplacement(data) {
if (this.onreadystatechange) {
if (typeof (this.miniprofiler) === 'undefined' || typeof (this.miniprofiler.prev_onreadystatechange) === 'undefined') {
this.miniprofiler = { prev_onreadystatechange: this.onreadystatechange };
this.onreadystatechange = function onReadyStateChangeReplacement() {
if (this.readyState === 4) {
handleXHR(this);
}
if (this.miniprofiler.prev_onreadystatechange != null) {
return this.miniprofiler.prev_onreadystatechange.apply(this, arguments);
}
};
}
} else if (this.onload) {
if (typeof (this.miniprofiler) === 'undefined' || typeof (this.miniprofiler.prev_onload) === 'undefined') {
this.miniprofiler = { prev_onload: this.onload };
this.onload = function onLoadReplacement() {
handleXHR(this);
if (this.miniprofiler.prev_onload != null) {
return this.miniprofiler.prev_onload.apply(this, arguments);
}
};
}
}
Metadata
Metadata
Assignees
Labels
No labels