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

Most upvoted comments

@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 :

# app/config/config_dev.yml

web_profiler:
    toolbar: true
    intercept_redirects: false
    excluded_ajax_paths: '.*' # <= This disable the ajax logging

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).

web_profiler:
    toolbar: false

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?

@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;

Downgrade to 3.4.4 doesn’t help with Flex.

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 of composer 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).

  1. Unzip the following file in Your project’s root directory: profiler.patch.zip
  2. Add the following code to composer.json "post-install-cmd": [ "patch -p0 -N < profiler.patch" ],

@nicolas-grekas Thanks for the advice, this solves the problem for Symfony 3.4:

  1. composer unpack profiler
  2. replace symfony/web-profiler-bundle version with “=3.4.4”
  3. remove vendor/* contents
  4. composer install

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)