symfony: Debug toolbar breaks app - JS error: `tbody.rows.count is not a function`
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.4.5 |
Just updated a client’s project from 3.3 to 3.4 and now getting JS errors in console in both Firefox and Chrome, caused by https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig#L125
The error is:
TypeError: tbody.rows.count is not a function
After setting a breakpoint in the Chrome debugger, it looks like tbody.rows
is an HTMLCollection. According to https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection, it has no count method. That line should probably be tbody.rows.length
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 33
- Comments: 31 (17 by maintainers)
Commits related to this issue
- bug #26368 [WebProfilerBundle] Fix Debug toolbar breaks app (xkobal) This PR was squashed before being merged into the 2.7 branch (closes #26368). Discussion ---------- [WebProfilerBundle] Fix Debu... — committed to symfony/symfony by nicolas-grekas 6 years ago
- minor #26373 [WebProfilerBundle] fix wrong variable for profiler counting ajax requests (Marin Nicolae) This PR was squashed before being merged into the 2.7 branch (closes #26373). Discussion -----... — committed to symfony/symfony by nicolas-grekas 6 years ago
- Add conflict with Symfony 3.4.5 due to https://github.com/symfony/symfony/issues/26364 — committed to emodric/ezplatform-legacy by emodric 6 years ago
@nicolas-grekas having the debug toolbar broken during one month is not a good DX though.
We don’t do quick fixes usually…
Sorry for this, I feel bad about it since I tested it, maybe I’ve changed it at some point…
If you cannot wait for the release of SF 3.4.6, you can still set the wdt configuration as that :
I’ve resolved this issue on my site by editing vendor/symfony/web-profiler-bundle/Resources/views/Profiler/base_js.html.twig file, in which this line:
var nbOfAjaxRequest = tbody.rows.count();
has been changed to:var nbOfAjaxRequest = tbody.rows.length;
After that the web-profiler and AJAX queries resumed working. I think the fix update is coming soon, and small editing for now is much better than downgrade to previous versions.@silentiumtempus You can always downgrade to 3.4.4. But we just disabled the developer toolbar in our
config_dev.yml
until the issue has been fixed (does not hurt that much because 95% of our requests are Ajax requests).This removes just the toolbar but keeps the profiler itself working.
@nicolas-grekas Will there be a quick 3.4.6 release with this fix?
@alexandre-le-borgne, 4.0.6 is already available with fix: http://symfony.com/blog/symfony-4-0-6-released
@silentiumtempus you don’t need to change any entry. Just add a new one in require-dev: “symfony/web-profiler-bundle”: “3.4.4”
it works with
var nbOfAjaxRequest = tbody.rows.length;
What do you mean? With Flex, just require symfony/web-profiler-bundle 3.4.4 (or 4.0.4 depending on your major version)
This is now fixed in new symfony release: http://symfony.com/blog/symfony-3-4-6-released
@phpeek Add a conflict for
symfony/symfony
v3.4.5, that should take care ofcomposer validate --strict
😃Here is a quick and dirty workaround for those who are too impatient or not willing to downgrade (tested on 4.0.5).
composer.json
"post-install-cmd": [ "patch -p0 -N < profiler.patch" ],
@nicolas-grekas Thanks for the advice, this solves the problem for Symfony 3.4:
This way I kept other symfony components updated to 3.4.5.
Actually if you use
symfony/profiler-pack
, you may need to remove it, and “unpack” it (ie explicitly list its entries in your own composer.json)Ping @simperfit