Using the old runtime I could set a breakpoint anywhere in my code. With the new v8 runtime breakpoints apparently have to be in the function I run from the debugger?
Is this intended behavior? Am I doing something wrong in the debugger, or in my code? Is it not structured correctly, perhaps?
MINIMAL EXAMPLE:
var test1 = 1;
var test2 = 2;
var test3 = 3;
function myFunction() {
var test4 = 4;
var test5 = 5;
}
V8 RUNTIME:
I can set a breakpoint on var test4 = 4
and then use the debugger and select myFunction
, and the code breaks on that line.
But if I set the breakpoint on var test2 = 2
and then use the debugger, selecting myFunction
, it doesn't break (It would with the old runtime).
On one hand side
From the documentation:
When run in debug mode a script pauses when it hits a breakpoint, which is a line you've highlighted in your script
If your breakpoint is located outside of the function - in a line that is never been called - your breakpoint will never be hit.
Other people also noticed that this behavior is different from before and filed it on Google's Public Issue Tracker
While Google investigates either the previous or the current behavior is the intended one, as a workaround:
If you want your debugger to stop on the line var test2 = 2;
which is outside of myFunction()
, you need to structure your code differently, e.g.: