vscode-js-debug
vscode-js-debug copied to clipboard
Sometimes, Closure Variables are not available in the Debug Console / Watch window
Sometimes, variables from the Closure section are not available in the Debug Console / Watch window:

This is what the debug console reports:

I wonder whether there is a way to overcome that.
This is the same as https://github.com/microsoft/vscode/issues/12066. I want to look at tacking that at some point... it's a good chunk of work. It requires the debugger to parse and understand the runtime scripts, because sourcemaps only give us a mapping between source positions and names, it doesn't say "here's a variable, here's a function argument." At the moment, we never look at source content or try to parse anything, we rely only in CDP messages from the debug targets.
Participation of the source content in debugging will also unlock a few other advanced scenarios, such as smarter deminification, referenced in https://github.com/microsoft/vscode-js-debug/issues/371#issuecomment-595312517
Thanks for your quick response on a Saturday ;)
Variable mapping would be awesome too, but this issue is about closure variables. As you can see, vscode_1 is in the closure and vscode can explore the content, but it is not accessible in the Debug console. I guess this is a nodejs problem though - I will try to reproduce the issue with the chrome debugger for nodejs.
Or did I misunderstand you?
Oh, apologies.
That's a V8 optimization, it optimizes away variables unused in the current scope. However we could be clever and hoist those like we do $returnValue.
@connor4312 is there any way to disable such optimization ? I tried several node flags without success. This gets really annoying during some debug sessions.
EDIT : even if it means we have to recompile node
Maybe, but I'm not an expert on v8 internals