-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Debugger setting a different 'this' than node.js when using arrow functions #44785
Comments
I've compared the behaviour of VS Code and Chrome Dev Tools. Here is the Chrome Dev Tools state for the two breakpoints. The Scope view (Variables view in VS Code) shows no difference for both breakpoints in CDT and in VS Code (which seems to be a bug both in VS Code and CDT). Evaluating "this" in the REPL results in VS Code in this: Which is the same as in CDT: So, VS Code and CDT behave the same. But I see a difference when hovering over "this". In VS Code there are no differences (which is the bug), but in CDT they differ. The problem is that VS Code implements the hover by matching variables against the information available in the Variables view. Since there are no differences shown in that view the hover does not show any differences either. If I enable an option in VS Code to implement the hover by using "evaluate", the problem is solved: Here is the hover in CDT (and the discrepancy between hover and scope view): @roblourens @isidorn should we turn on evaluate based hovers for node-debug? |
/findDuplicates |
This is #13967 dupe bot found one but not the original. It is fixed in Chrome so the fix should be coming down the pipeline to newer node versions very soon. |
I don't think we should turn it on to work around this one bug, although it's been filed a few times now. I wouldn't want to trigger side effects in getters without an explicit evaluate step like Chrome devtools has. |
@roblourens why don't we turn on evalute on hover at least for insiders to get some feedback before making a final decision? |
I'm wrong, if you hover over In vscode we invoke It's still worth trying though. |
@roblourens there have not been so many issues lately, but through history I remember people always complaing about this. Another idea is to do evaluate when our first strategy does not find any results. So to do evaluate as a fallback. We would probably need a new capability for this though. |
I updated my vscode insiders to latest version and still get this to reference the object, both by side panel and by hovering. Was this implemented yet? |
Also worth nothing, when I used google chrome my results differ from @weinand, as CDT was showing the correct result in both hovering and side panel. |
It's not checked in to Insiders yet. |
Steps to Reproduce:
Which implies that the 'this' inside the arrow function is undefined (as should be), however if you add a breakpoints on:
You will notice the 'this' value in the debugger is the same in both functions! so for some reason it's not binding to node 'this'
Note: Tested on chrome browser debugger and the expected 'this' value (which is undefined) appears for the arrow function, so this problem is related to vs code only.
The text was updated successfully, but these errors were encountered: