21

Whether I set breakpoints directly on the source/console or add a debugger on my code, the browser doesn't seem to respond to them. Any ideas why? Here's my code:

 if (select[i].placeholder != undefined && select[i].placeholder != '' ) {
        selected.appendChild(document.createTextNode(select[i].placeholder)); debugger;
    } else if (select[i].options[0].value == '' && select[i].options[0].textContent != '' ) {
        selected.appendChild(document.createTextNode(select[i].placeholder));
    } else {
        selected.appendChild(document.createTextNode('Select an option'));
    }
1
  • I see you've accepted an answer saying they weren't being hit because the code where you had the breakpoint wasn't being reached in the control flow. Is that really what the problem was? You had (say) a breakpoint on the second line above, but the condition above that line was false? Commented Nov 14, 2017 at 18:00

8 Answers 8

42

In Dev Tools, on the Sources panel, there's a button that looks like a breakpoint marker with a line through it: That button disables all breakpoints. To re-enable them, click the button.

Here's what it looks like when they are currently enabled (clicking it disables them):

enter image description here

...and when they are currently disabled (clicking it enables them):

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

In my case i just had to restart chrome. Spend an hour to figure out!
@YashVekaria - Restart what? You certainly don't need to restart anything just to turn breakpoints on and off in Chrome. You might be best off posting a new, complete question with a full description of what you're doing, what you're restarting, what happens if you don't, etc. Then people will be able to help.
This happened to me a few times before, and then just called it for the day. Toggling this seems to have sorted it out. Thanks.
18

Restarting the app worked for me.

2 Comments

Not sure why this was downvoted, but that's what I have to do on a regular basis when Chrome suddenly stops stopping on breakpoints. I guess there's some kind of a bug in Chrome itself.
Restarting chrome in Nov 2024 worked
6

Chrome is not fond of webpack lazy loaded components and breaks down regularly.. Sometimes if there is an error which doesn't prevent other code from running it still prevents breakpoints from working anyway.. super annoying.. restarting chrome and/or updating it seems to be the only help. It doesn't always work to update/restart though..

Comments

6

I've found that if I ran the page while I was on the "Console" tab, the breakpoints work, and if I was in the "Sources" tab (say, looking at the code with the breakpoints), it did not. So, I switched back to the "Console" tab and reloaded the page and it works.

Chrome 91.0.4472.106 on OS X.

EDIT: Although that didn't seem to always work for me. Another thing I did is remove and re-add the breakpoints.

2 Comments

Switching to the "Console" tab works for me in "92.0.4515.107 (Official Build) (64-bit)" on Windows 10.
This worked for me. Chrome LInux 97.0.4692.71
3

I think I see what is happening. Typically, you should not add breakpoints in the middle of an if statement. That's because if the statement is false, then it will not run that line and therefore 'jump' over the debugger or breakpoint.

Therefore, add your debugger; before or after the if-statement

/* Here -- debugger;*/
if (select[i].placeholder != undefined && select[i].placeholder != '' ) {
    selected.appendChild(document.createTextNode(select[i].placeholder)); 
} else if (select[i].options[0].value == '' && select[i].options[0].textContent != '' ) {
    selected.appendChild(document.createTextNode(select[i].placeholder));
} else {
    selected.appendChild(document.createTextNode('Select an option'));
}
/* Or Here -- debugger;*/

Depending on what you hope to capture with the debugging...

1 Comment

Having found this item (because my breakpoints ARE being ignored by chrome) I think the title should be changed - chrome is not ignoring breakpoints. The question should be please help me put my breakpoints in the correct place.
2

For me restaring or changing debugger settings didn't work. In development mode of Material-UI (V4) app with babel.config:

export const presets = [
  ['@babel/preset-env', { targets: { node: 'current' } }],
  '@babel/preset-typescript',
];

My source file was somehow duplicated and I put breakpoint in a wrong file (with the same name). I have opened CORRECT file by choosing source from console log. enter image description here enter image description here

I think the issue was that old mappings were saved because I put a breakpoint while my React app (with live Hot Reaload mode) was rerendered.

Comments

0

Check your console first, sometimes there are errors in your script and the script is not even running, fix those errors first, and eventually the debugger should start working.

Comments

-1

Another situation: the breakpoint is in a function/method which is never invoked because of a type error or something else.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.