Jump to content

Debug bar does not appear on one specific front-end page, despite appearing on all others.


Recommended Posts

Posted

Hello!

I wondered if anyone knows how to troubleshoot this. I have one specific page where the the Tracy debug bar doesn't load, so I can't access the output of bd() and other Tracy functions. The debug bar does appear in the ProcessWire back-end and every other front-end page I checked.

My first thought was that, for some reason, ProcessWire didn't think I was logged in as a superuser on that page, but I echoed $user->name, and it showed my superuser username. For good measure, I also echoed $user->hasPermission('tracy-debugger'), and got the output "1".

I checked the TracyDebugger module settings to see if I misconfigured something, and couldn't find anything obviously wrong:

  • "Enable TracyDebugger" is checked.
  • "Output mode" is set to "DEVELOPMENT".
  • "Force superusers" and "guest users into DEVELOPMENT mode" are both unchecked. I checked them and reloaded just in case and got the same behavior.
  • "Show debug bar" is checked for "Frontend" and "Backend".
  • "No debug bar in…" is unchecked for all modes.

I'm sure the solution will seem obvious in hindsight, I just can't foresee it.

Thanks in advance for any guidance!

 

Posted

No. No errors in the browser console, nor do I see any errors logged in ProcessWire's error log under "Setup » Logs". For what it's worth, the page does not seem to be loading any front-end scripts at all from TracyDebugger. On other pages where the debug bar loads, I see a huge wodge of markup appended to the markup I wrote, starting with <!-- Tracy Debug Bar -->. The affected page has no appended script elements at all.

I see I can make the debug bar appear if I uncomment two lines of code that were throwing a fatal error.

Posted
19 hours ago, johnstephens said:

I see I can make the debug bar appear if I uncomment two lines of code that were throwing a fatal error.

I'd be interested to see that code to see if there is something I can do to prevent Tracey from not capturing that error and breaking it from loading.

  • Like 1
Posted

I'm willing to share it, but I don't know how much would be useful.

I started with something like this:

This problem of TracyDebugger failing to load came up after adding code to compose the site's parent/child hierarchy using the imported articles.

The specific lines that throw the fatal error are these:

$newArticle->alert->setLanguageValue($en, $article['alert_en']);
$newArticle->alert->setLanguageValue($es, $article['alert_es']);

When those lines are included, Tracy's debug bar loads and shows me the stack trace of the error. The reported error is "Call to a member function setLanguageValue() on null", which doesn't make sense to me. I verified that the 'alert' field is attached to the template AND that it's correctly configured as a multi-language textarea (as opposed to a regular textarea, which wouldn't support the setLanguageValue() method).

I commented out those lines to simply dump the $newArticle object using bd(), and the actual script executes without any errors or warnings—but then Tracy's debug bar vanishes. I wonder what could stop the debug bar from loading?

I hope this helps. Thank you, @adrian!

  • 2 weeks later...
Posted

I've done a lot of testing, and my hunch is that the script is running out of memory—specifically when I invoke bd().

What I'm doing is this:

  1. Query a MySQL database with $database->query().
  2. Use foreach to loop through the results.
  3. Each iteration of the loop, I select a $parent page based on data from the query and create a new page with $pages->add().

If I invoke bd() within the loop, TracyDebugger fails to load. If I don't invoke bd() in the loop, the debug bar loads.

Posted

Hi @johnstephens - thanks for looking into it further - sorry I didn't respond to your last message - I didn't really see anything I could use to reproduce it.

It does sound like you might be onto something with the memory error idea.

I am curious what is in your bd() call - are there a lot or heavy objects being dumped? How many results are you looping through?

If I try to dump too many items, eg:

for($i=0;$i<99999999;$i++) {
    bd($i);
}

And I do get an out of memory fatal error and the debug bar fails to load, but I fixed it by increasing the "Reversed memory size" option in Tracy's config settings. Please let me know if that works for you.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...