Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EvalError: Possible side-effect in debug-evaluate in Google Chrome

I get this error in the Chrome console every time I try to evaluate an expression.

EvalError: Possible side-effect in debug-evaluate

What could be causing it?

like image 732
Mohammad Mohagheghian Avatar asked Aug 30 '25 15:08

Mohammad Mohagheghian


2 Answers

I think I found the issue, reading through a discussion on an electron issues board.

It could potentially be caused by this: [inspector] Add custom error dispatch machinery for debug evaluate.

And hopefully fixed in this: [inspector] Don't trigger window.onerror with side-effects disabled.

This was an oversight in https://crrev.com/c/3557234, which led to a really weird developer experience: once a window.onerror handler was installed, typing into the Console or other side-effect free debug evaluations triggered this handler.

like image 194
redfox05 Avatar answered Sep 13 '25 02:09

redfox05


The website you are inspecting contains an onerror event listener.

A new bug in the latest version of Chrome triggers this event every time an expression is evaluated in DevTools. This includes live expressions and the console.

If this is your own website, add this line of JavaScript to your event listener to ignore any errors triggered outside of a script, where script is the second argument of the event listener function:

if(!script.endsWith(".js")) return;

Note that this will only work for external JavaScript (in .js files), in the case of JavaScript embedded in HTML <script> tags, it will disable your event listener entirely.


If this is not your website, you can temporarily disable the event listener in DevTools, like this:

  1. At the top of DevTools, open the "Elements" tab
  2. Press "»", on the right of "Styles", "Computed", "Layout"
  3. Choose "Event listeners"
  4. Find and expand "onerror"
  5. Click "Remove"

This will remove the event listener, but the issue will return after you refresh the page.

Hopefully the next version of Chrome will fix this bug.

like image 38
Tikolu Avatar answered Sep 13 '25 01:09

Tikolu