nodejs / node

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

Debugger doesn't pause again after stepping through blackboxed function #30903

Open roblourens opened 4 years ago

roblourens commented 4 years ago

Have a script like

// test.js
debugger;
console.log('hello there');
for (var i = 0; i < 100; i++) {
    console.log('helllo there')
}

I am not sure whether this is node-specific but I wasn't able to come up with a repro in Chrome. It worked at least in Node 8.

If I set up other scenarios of stepping into node code with this blackbox pattern set, sometimes it works and sometimes I see other wrong behavior - it pauses in internal/per_context/primordials.js even though that script is marked as "This script is blackboxewd in debugger"

gireeshpunathil commented 3 years ago

copying @RafaelGSS who might be interested as well, as he is doing some research / work on this area.

RafaelGSS commented 3 years ago

I couldn't reproduce it on node v8.17.0 as well. However, in v16 using ^node: in the ignore list looks working as expected. I know that this issue is old but, can you validate it? @roblourens

roblourens commented 3 years ago

A different problem in v16, it stops on a line which it says is in the ignore list, and it should not stop there

image

RafaelGSS commented 3 years ago

Yes, same behavior here, however, I feel that it's expected? cc: @nodejs/inspector

roblourens commented 3 years ago

Why would it be expected to step into an ignored file? It's been a long time since I worked on this stuff but I'm pretty sure I just expect it to step through the ignored stuff into the next line of user code

RafaelGSS commented 3 years ago

I'm saying it because in the newer versions we see that message as you showed above.

For instance, if you add a debugger in a file that is inside ignore-list:

// example-blackbox.js
module.exports = {
  doSomethingAsync: async () => {
    debugger
    console.log('Async done')
  }
}
const { doSomethingAsync } = require('./example-blackbox')
async function main() {
  await doSomethingAsync()
  console.log('Done!')
}
main()
node inspect index.js
debug> Debugger.setBlackboxPatterns({ patterns: ['example-blackbox.js'] })

and the code is not reachable (as expected). So it might be an expected thing. Although, the step into entering in an ignored script still looks like your example.