
Ask HN: How do you deal with “slipping breakpoints” in JavaScript debuggers? - jakub_g
This has been annoying me ever since I started working as a JS dev.<p>Say you have a 100 line file, you put breakpoint in L80 in Chrome devtools. Then you add a line at the beginning, and L80 becomes L81. The breakpoint I just put a minute ago can fall on an empty line and never execute.<p>I know about `debugger` which is quite handy sometimes, but it&#x27;s not very feasible to pollute whole codebase with it during debugging session.<p>Any other options?
======
lollipop25
This depends on the browser. Dev tools are "smart". It knows where you should
put a breakpoint (i.e: putting it on a blank line, it puts it on the next
executable line instead). It also knows when you adjusted your script (i.e.:
removing a line above, it moves up the breakpoint).

"slipping" can happen if:

\- The dev tools can't determine where to move the breakpoint (i.e.: if you
significantly changed the file). Just re-assign the breakpoint.

\- It can also happen when you use a badly-constructed source map. Disable
source maps and work with raw code, and contact the tool-maker about this.

\- Sometimes, the dev tools will just go crazy. Just close and reopen.

\- debugger. You have no choice.

