Skip to content

Commit 2a40b6f

Browse files
committed
bug symfony#22300 [WebProfiler] Fix race condition in fast Ajax requests (curry684)
This PR was merged into the 3.3-dev branch. Discussion ---------- [WebProfiler] Fix race condition in fast Ajax requests | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#22297 | License | MIT Patch `startAjaxRequest` and `finishAjaxRequest` functions to absolute noop in case the debug toolbar itself is not loaded yet, and spool historic requests after the toolbar is loaded. Commits ------- 538a592 [WebProfiler] Fix race condition in fast Ajax requests
2 parents 54495b2 + 538a592 commit 2a40b6f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@
117117
};
118118
119119
var startAjaxRequest = function(index) {
120-
var request = requestStack[index];
121-
pendingRequests++;
122-
var row = document.createElement('tr');
123-
request.DOMNode = row;
124-
125120
var tbody = document.querySelector('.sf-toolbar-ajax-request-list');
126121
if (!tbody) {
127122
return;
128123
}
129124
125+
var request = requestStack[index];
126+
pendingRequests++;
127+
var row = document.createElement('tr');
128+
request.DOMNode = row;
129+
130130
var methodCell = document.createElement('td');
131131
methodCell.textContent = request.method;
132132
row.appendChild(methodCell);
@@ -171,6 +171,9 @@
171171
172172
var finishAjaxRequest = function(index) {
173173
var request = requestStack[index];
174+
if (!request.DOMNode) {
175+
return;
176+
}
174177
pendingRequests--;
175178
var row = request.DOMNode;
176179
/* Unpack the children from the row */
@@ -356,6 +359,12 @@
356359
el.innerHTML = xhr.responseText;
357360
el.setAttribute('data-sfurl', url);
358361
removeClass(el, 'loading');
362+
for (var i = 0; i < requestStack.length; i++) {
363+
startAjaxRequest(i);
364+
if (requestStack[i].duration) {
365+
finishAjaxRequest(i);
366+
}
367+
}
359368
(onSuccess || noop)(xhr, el);
360369
},
361370
function(xhr) { (onError || noop)(xhr, el); },

0 commit comments

Comments
 (0)