From b7c0242cb37a31aba587337b01422c0ecee5da6c Mon Sep 17 00:00:00 2001 From: wuyangfan Date: Mon, 25 May 2026 16:12:27 +0800 Subject: [PATCH] fix: hook XMLHttpRequest onloadend for axios compatibility (#674) Axios switched from onreadystatechange to onloadend in 2021, so the MiniProfiler XHR wrapper never saw completed axios requests. Wrap onloadend the same way as onload to fetch profiler results. Co-authored-by: Cursor --- src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts b/src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts index fb97d051..915e2b9e 100755 --- a/src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts +++ b/src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts @@ -1365,6 +1365,18 @@ namespace StackExchange.Profiling { } }; } + } else if (this.onloadend) { + if (typeof (this.miniprofiler) === 'undefined' || typeof (this.miniprofiler.prev_onloadend) === 'undefined') { + this.miniprofiler = { prev_onloadend: this.onloadend }; + + this.onloadend = function onLoadEndReplacement() { + handleXHR(this); + + if (this.miniprofiler.prev_onloadend != null) { + return this.miniprofiler.prev_onloadend.apply(this, arguments); + } + }; + } } else if (this.onload) { if (typeof (this.miniprofiler) === 'undefined' || typeof (this.miniprofiler.prev_onload) === 'undefined') { this.miniprofiler = { prev_onload: this.onload };