• I’d been having problems debugging *my* JavaScript- embedded in a WP page. It was crashing with no sign of the cause- a typo which *should* have resulted in an “Uncaught ReferenceError” on the developer console but didn’t.

    At first I thought this was a Firefox config issue, but behaviour in Chrome was identical, and a non-WP test page displayed the error correctly in both.

    I eventually remembered that jQuery Migrate Helper (which was enabled) intercepted exceptions and wondered if that was the cause. Lo and behold, when it was disabled, the “Uncaught ReferenceError” (in *my* code) appeared as expected. When it was re-enabled, my error was hidden.

    Is this known and expected behaviour for the “Enable JQuery Migrate Helper” plugin?

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @raspberryade are you able to share the code which was having this issue with the plugin?

    Thread Starter Raspberryade

    (@raspberryade)

    Thanks for your response @thelmachido. You should be able to repeat it by pasting the following into the main text of an empty article page (I use the classic editor “text” tab to ensure it appears as-is within the page HTML).

    <script type='text/javascript'>undefined_variable.value = "arbitrary";</script>

    Then simply preview the article.

    I’ve tried it with two different themes, the result is the same with both.

    If the plugin isn’t enabled, I get “Uncaught ReferenceError: undefined_variable is not defined” on the console (as expected). If it’s enabled, I don’t.

    I’m just wondering if this is a known issue.

    • This reply was modified 1 year, 5 months ago by Raspberryade.
    • This reply was modified 1 year, 5 months ago by Raspberryade.

    Thank you for the details, @raspberryade

    If the plugin isn’t enabled, I get “Uncaught ReferenceError: undefined_variable is not defined” on the console (as expected). If it’s enabled, I don’t. I’m just wondering if this is a known issue.

    I am going to defer to @clorith, he’s in the best position to confirm this.

    Thread Starter Raspberryade

    (@raspberryade)

    @mrfoxtalbot; Much appreciated.

    I should make clear that this isn’t a showstopper for me so much as a minor nuisance that *can* be worked round (though I’d rather not have to if it was trivially fixable(!)) and enough of an apparent oddity that I thought it was worth raising.

    If no-one else was able to reproduce the issue with the code snippet above, I’d assume the problem was with my installation and not worry about it.

    Plugin Author Marius L. J.

    (@clorith)

    Hiya! It’s definitely something we can replicate, although not directly intentional, there’s a good reason why it does happen.

    So to capture jQuery deprecation/fatal errors, a global error handler is added by this plugin. A side effect of this is that any code that does not it self implement error handling will be caught by the same check, and thus be suppressed).

    That said, it may be worthwhile looking into surfacing any errors that are not covered by the jQuery checks (if anyone would like to help with that, the code is available at https://github.com/WordPress/jquery-migrate-helper)

    Thread Starter Raspberryade

    (@raspberryade)

    @clorith; That at least confirms my original suspicion that it had something to do with interception of errors.

    Thanks for the feedback and taking the time to take this on board (and thank you for your work on the plugin as well!)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Interference with error handling and console logging?’ is closed to new replies.