80

enter image description here

In the image above, I tried setting breakpoints on every line from line 437 to line 443. However, I cannot set breakpoints on lines 439 and 440. When the function runs, the breakpoints on lines 437, 438, 441, and 442 are ignored. Chrome breaks on line 443. This means that I cannot do some debugging before the first conditional runs.

When I click on lines 439 or 440, the breakpoint appears for half a second and jumps to line 443.

Is this a bug or am I missing something? How do I set a breakpoint at or before line 439?

Leo Jiang
  • 21,891
  • 43
  • 133
  • 242

7 Answers7

19

If you are using js minification and sourcemaps, ensure that they are up to date with your source code.

Danila Shutov
  • 464
  • 2
  • 12
  • 2
    My sourcemaps should be up to date, but that's a pretty good clue. Here's someone with a similar problem who's using Closure: http://stackoverflow.com/questions/20013786/my-source-mapped-breakpoints-arent-working-correctly-in-google-chrome. I'm also using Closure. I'll take another look tomorrow. – Leo Jiang Feb 09 '16 at 08:58
  • @Linksku , there also another threat: some of the folks are prepenfing info to the concatenated file. For example global configuration or something like that. And because of that sourcemaps can become useless too. – Danila Shutov Feb 09 '16 at 09:08
  • 3
    @DanilaShutov How do you make sure that sourcemaps etc are up to date? This Chrome debugger error has been happening for a while for me, and it's very frustrating – reectrix Apr 07 '16 at 12:35
  • 1
    @am5255, just try to build your app without minification and check if debugger works as expected. If it will, then certainly there is something wrong with build scripts. Also check this link: http://fitzgeraldnick.com/weblog/51/ I encountered this issue only once: when I attempted to prepend script with configuration to minified bundle and forgot to include that script in sourcemaps complitaion. Because of that sourcemaps become invalid and debuggers been acting like topic starter described. – Danila Shutov Apr 08 '16 at 08:30
  • Unfortunately as of 06.2017 the link I've posted no longer works. Author changed how his blog works so article is actualy there but the link is broken. – Danila Shutov Jun 02 '17 at 10:03
  • 1
    got the exact same issue I have to add an unused variable before, then I can set the break point my code is definetely in sync with my build so it is clearly a bug – Phil Nov 10 '17 at 10:32
10

I have same problem in chrome dev tool source panel snippets when I write some codes to test my idea.

Only way for me worked is close dev tool panel and refresh page then reopen

This problem happened after I modified codes in debug mode

nuclear
  • 2,779
  • 3
  • 16
  • 32
3

This was frustrating for me today but I found the problem. I was trying to place a breakpoint inside an orphan function (nothing was calling it). As soon as I fixed it, all was well. Smart - but wish there was even a tiny hint that this was the case.

rmasrani
  • 41
  • 3
1

This recently became an issue for me, running System.js and Babel, and with plain ES6 transpiling, I haven't gotten to minifying/mapping yet. A workaround seems to be to add your breakpoint to the !transpiled file, a matching breakpoint will automagically appear in the corresponding line in the raw file.

Shukri Adams
  • 740
  • 10
  • 25
  • was having the same issue with `Typescript`. Set a break point in the transpiled file magically jumps to the `ts` file where i could not set break point by click... really odd but worked somehow. Thanks! – LeOn - Han Li Oct 02 '18 at 19:56
0

I think that my classmate and I had this issue as well today. We made our changes and then hit Ctrl + S (or Cmd + S) to save the changes in the debugger and then we were able to add the breakpoints.

0

In my case, I could not put a break point on the calling function line, but it worked into the function... weird but at least it works.

Francois Girard
  • 310
  • 3
  • 13
0

I just had that problem and realized that what I saw in the dev tools source was not the code that actually ran in the browser.

Make sure you empty your cache and reload and have the up to date code.

Flip
  • 5,443
  • 6
  • 39
  • 69