nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.41k stars 29k forks source link

"breakpoints" command not listing breakpoints: "No breakpoints yet" #41790

Open cirosantilli opened 3 years ago

cirosantilli commented 3 years ago

Hi, is this the upstream for what I describe below? :-)

main.js

#!/usr/bin/env node

function myfunc(i) {
  return i + 1;
}

let i = 1;
i += 1;
console.log(myfunc(i));

Start debugging:

node inspect main.js

Leaves me at:

Break on start in main.js:7
  5 }
  6 
> 7 let i = 1;
  8 i += 1;
  9 console.log(myfunc(i));

Now I set a breakpoint successfully:

sb('myfunc()')

but when I then run:

breakpoints

it just shows:


debug> breakpoints
No breakpoints yet

But help says: https://github.com/nodejs/node-inspect/blob/643179ef5e0452a52ceef2c5e7c8ca42ab00280f/lib/internal/inspect_repl.js#L57

Tested on node v14.15.3.

copperwall commented 3 years ago

That's interesting, it looks like ends up calling debug from the Command Line API instead of Debugger.setBreakpoint, so there's not enough info from debug to track it, even though the debugger will stop at that function.

Using debug in Chrome Dev Tools also doesn't show a breakpoint in the Sources tab either.

I wonder if the tool could store a special type of breakpoint in knownBreakpoints for listing it out, and then calling undebug if you call clearBreakpoint with a function name instead of a url/line.

It does look like it's currently matching the Chrome debugger behavior.

jkrems commented 2 years ago

Thanks for the report! I think that would be a nice feature and I assume a PR adding this feature would likely be merged.

rotu commented 1 month ago

Still an issue in Node 22.4.1.