Ask HN: How do you deal with “slipping breakpoints” in JavaScript debuggers?
This has been annoying me ever since I started working as a JS dev.
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.
I know about `debugger` which is quite handy sometimes, but it's not very feasible to pollute whole codebase with it during debugging session.
Any other options?
"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.