user3389206
user3389206

Reputation: 495

Why doesn't debugger stop at breakpoint?

I have the problem that the chrome debugger for JS doesn't stop every time I execute one certain function. I tried debugger; and also setting breakpoints where I want the code to stop by putting a blue tag on the gutter next to the line on the left.

any ideas why this happens?

Upvotes: 44

Views: 56792

Answers (14)

rosethorn
rosethorn

Reputation: 91

Had you add folder to workspace accidentally?
If yes, your devTool breakPoint would stop work on this file.
enter image description here

After I remove folder from workspace, breakpoint feature is back!
enter image description here

Upvotes: 1

Jeff Luyet
Jeff Luyet

Reputation: 502

This may sound dumb... but it worked for me... Simply closing and re-opening the browser restored JS debugging functionality.

Upvotes: 2

rosethorn
rosethorn

Reputation: 91

Maybe you add your target file to blackbox, so debugger could not be triggered on it.

add to blacked script solve: notice remove blacked

ref: https://developer.chrome.com/devtools/docs/blackboxing

Upvotes: 1

Elliott Beach
Elliott Beach

Reputation: 11483

For me this appears to be a bug in chrome - nothing would cause a breakpoint to be hit, not even debugger. I had to close and re-open Chrome, and then my breakpoints worked.

Upvotes: 8

user2980294
user2980294

Reputation: 1

If you are using the VS, check if configuration is DEBUG. When is Release the MVC minify the JS.

Upvotes: -1

Krasimir Georgiev
Krasimir Georgiev

Reputation: 1

I had the same problem and it turned out that reason was that I had enabled bundle, i.e. in the BundleConfig.cs I had BundleTable.EnableOptimizations = true; When I changed it to BundleTable.EnableOptimizations = false; it worked.......

Upvotes: -1

Dias
Dias

Reputation: 11

I found that code referenced by a tag with the async property inside of it don't stop at breakpoints in developer mode.

Upvotes: 1

Shubham Gupta
Shubham Gupta

Reputation: 424

Check if your function is called properly. For me, I resolved the problem by conceptualising the flow of my program and found out that the function calling had some errors. After figuring that out, it was easy to continue.

Upvotes: -1

Mike T
Mike T

Reputation: 614

Also, it's possible that breakpoints are disabled. You can toggle this in the debugger or by pressing Ctrl + F8

Upvotes: 2

Subin Ninan
Subin Ninan

Reputation: 1

With client solutions like angular js, the modules and controllers are picked up independent of the file name. Most probably you would have created a backup/copy of file in the same folder as the actual file you are debugging. This might be the js file getting called instead of one you intended. You can delete that file and it should work fine.

Upvotes: 0

Matt
Matt

Reputation: 6340

What I found worked was to set my breakpoints using the suggestions above, then in the extension's console run:
location.reload(true);

This re-opens the extensions, set off my breakpoints and allowed me to debug!

It appears that the problem is related to the debugger loading after the extension, thus not capturing the breakpoints. Hope that helps!

Upvotes: 19

Jack Ofnotrade
Jack Ofnotrade

Reputation: 41

I had an issue with breakpoints being hit that I just resolved. Breakpoints within javascript in the html were not being hit, although I could set and hit breakpoints in included Javascript files.

I found that the problem was that the source file was included twice. The base html page (not dynamically included) has the sourceURL tag in it. This caused the same javascript to exist twice in the source pane, causing the issue.

I removed the "sourceURL" tag from the base html page, and breakpoint resumed working

Upvotes: 4

Zafar
Zafar

Reputation: 3434

Without a clear reproduction plan, it is very hard to tell why your breakpoints are not hitting.

But, one surest way of stopping on a line is writing:

debugger;

to the location where you want to stop. Without any blue signs on the gutter, the debugger will halt.

NOTE: Be sure to clear all the debugger; when you are done with it.

More info is here

Upvotes: 36

Vishal Sharma
Vishal Sharma

Reputation: 2803

to test your function debug point you can call that function right from console.. it will call and hit your breakpoint

Upvotes: -1

Related Questions