Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step Into for Generator Function triggers Continue #29079

Open
cefn opened this issue Aug 10, 2019 · 0 comments

Comments

@cefn
Copy link

commented Aug 10, 2019

  • Version: v12.4.0
  • Platform: Linux cefn-bionic-thinkpad 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: Debugger protocol

When debugging, trying to STEP-IN to a generator function call causes the debugger session to CONTINUE.

This is inconsistent when...

  • STEP-IN on a regular function call triggers STEP-IN (steps to first line in the called function)
  • STEP-IN on a NON-function-call triggers STEP-OVER (steps to next line in the current function)
  • STEP-IN on a NON-function-call at the end of a function triggers STEP-OUT (steps to a line following the original function-call)

The above three seem to me to be correct behaviour, consistent with using STEP-IN as a shortcut for go-to-the-next-line-of-code.

This inconsistency is a particular problem because it is impossible to judge from the interactive debugger session whether the apparent function call you are stepping into is a generator or a regular function. Therefore you might try to STEP-IN, then find that the debugger has chosen to CONTINUE because it was a generator call, making that stack call in the debugger session unrecoverable unless you had another breakpoint to catch it. The only workaround is to have a 100% accurate model of which calls are generators and Never call STEP-IN on a generator call.

Taking the below example, assuming just two manually-inserted Debugger breakpoints.

  • One at run()
  • One at: console.log("Finished script"). This is jumped to if you hit CONTINUE at any time.

Pressing the STEP-IN control in Chrome Inspector or VSCode ...

  • STEP-IN on run() triggers STEP-IN
  • STEP-IN on const nothing = makeNothing() triggers STEP-IN
  • STEP-IN on functionRunning = makeNothing.name triggers STEP-OVER
  • STEP-IN on return triggers STEP-OUT
  • STEP-IN on const sequence = makeSequence(5) then surprisingly triggers CONTINUE - jumping to the next manually-inserted breakpoint at console.log("Finished script") instead of the expected behaviour - stepping over to the line console.log("Arbitrary logging")
let lastFunctionName = null

function makeNothing() {
  lastFunctionName = makeNothing.name
  return
}

function* makeSequence(limit) {
  lastFunctionName = makeSequence.name
  for (let i = 0; i < limit; i++) {
    yield i
  }
}

function run() {
  const nothing = makeNothing()
  const sequence = makeSequence(5)
  console.log("Arbitrary logging")
}

console.log("Starting script")
run()
console.log("X")
console.log("X")
console.log("X")
console.log("Finished script")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.