rails-profiler 0.44.33 → 0.44.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/app/assets/builds/profiler-toolbar.js +2 -2
- data/app/assets/builds/profiler.js +12 -12
- data/app/assets/javascript/profiler-ajax-interceptor.js +12 -3
- data/lib/profiler/version.rb +1 -1
- metadata +1 -1
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
23
23
|
const originalXHRSend = XMLHttpRequest.prototype.send;
|
|
24
24
|
const pendingXHRRequests = new WeakMap();
|
|
25
|
+
const xhrLoadListeners = new WeakMap();
|
|
25
26
|
// The fetches Turbo makes, by the AbortSignal it hands to fetch(): { frame: true } when the
|
|
26
27
|
// request loads a <turbo-frame>.
|
|
27
28
|
const turboRequests = new WeakMap();
|
|
@@ -175,7 +176,7 @@
|
|
|
175
176
|
|
|
176
177
|
// Override XMLHttpRequest.open()
|
|
177
178
|
XMLHttpRequest.prototype.open = function(method, url, ...args) {
|
|
178
|
-
const urlString = typeof url === 'string' ? url : url
|
|
179
|
+
const urlString = typeof url === 'string' ? url : String(url);
|
|
179
180
|
|
|
180
181
|
// Store request metadata
|
|
181
182
|
pendingXHRRequests.set(this, {
|
|
@@ -196,14 +197,22 @@
|
|
|
196
197
|
return originalXHRSend.apply(this, args);
|
|
197
198
|
}
|
|
198
199
|
|
|
200
|
+
// Remove any previous load listener to avoid duplicates on reused XHR instances
|
|
201
|
+
const previousListener = xhrLoadListeners.get(this);
|
|
202
|
+
if (previousListener) {
|
|
203
|
+
this.removeEventListener('load', previousListener);
|
|
204
|
+
}
|
|
205
|
+
|
|
199
206
|
// Add load event listener to capture response
|
|
200
|
-
|
|
207
|
+
const handleLoad = function() {
|
|
201
208
|
const profilerToken = this.getResponseHeader('X-Profiler-Token');
|
|
202
209
|
|
|
203
210
|
if (profilerToken && requestData) {
|
|
204
211
|
linkChildProfile(profilerToken);
|
|
205
212
|
}
|
|
206
|
-
}
|
|
213
|
+
};
|
|
214
|
+
this.addEventListener('load', handleLoad);
|
|
215
|
+
xhrLoadListeners.set(this, handleLoad);
|
|
207
216
|
|
|
208
217
|
return originalXHRSend.apply(this, args);
|
|
209
218
|
};
|
data/lib/profiler/version.rb
CHANGED