-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Support pausing the debugger on script load #24687
Comments
I believe that this method should be called setInstrumentationBreakpoint and should be part of Debugger domain, so it should be implemented in V8 and can be backported to Node 10. |
Seems like we should just expose the after-compile event to the devtools protocol? |
After compile events are exposed as |
|
So I guess could expose an option that can be enabled which causes the Debugger.scriptParsed event to behave like a debugger pause that needs manual resume? |
Do you envision this breakpoint to break at parsing/compiling, or upon execution? |
I prefer to emit regular |
Fixing http://crbug.com/724793 would be very helpful too! I think the break should happen immediately before execution. It should happen after +1 for
|
Iirc SetBreakOnNextFunctionCall would pause before we even enter the top-level function. Sgtm. |
We can actually provide sourceMappingURL and sourceURL inside data param of Debugger.paused to make it easier. |
Now that I think about this, triggering the pause at the after-compile event is probably more straightforward to implement. Otherwise we would have to schedule a pause and remember until that pause for what reason we paused (and what script URL to pass). |
We already have infrastructure for this use case - |
I uploaded patch for V8: CL. It looks good to me but definitely requires accurate review 😄 |
That was fast! This looks great, One question - what happens when this is enabled and there is a breakpoint on the first line of the script? Ideally, the debugger can
This API in Chrome used to work that way. Then at some point the behavior changed such that if we continue from the instrumentation bp, it will skip the user bp at 1,1, so we now have to check manually whether the user set a bp there. |
Any update here? Seems like the v8 CL is still open with some pending comments? |
Kevin was going to follow up since person who opened left Google. |
I addressed comments and I hope to get review and land my CL soon. It was very busy December and later I forgot about this thread - sorry! |
My commit was finally landed. Test might be good starting point to see how to use this new API. |
Just waiting on a backport to Node.js 12.x and then we can close |
Could someone approve backport #27720 please? :) |
Original commit message: inspector: added Debugger.setInstrumentationBreakpoint method There are two possible type: - scriptParsed - breakpoint for any script, - scriptWithSourceMapParsed - breakpoint for script with sourceMappingURL. When one of the breakpoints is set then for each matched script we add breakpoint on call to top level function of that script. Node: nodejs#24687
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There is a Node debugging scenario that doesn't work very well in vscode (or chrome devtools), but does in debugging Chrome, and I want to start a discussion about how we can improve this.
Typically when debugging a Node project with sourcemaps, the scripts are transpiled to disk, vscode's launch config points at these files with the "outFiles" parameter, then vscode preloads the sourcemaps so it can set breakpoints in the correct locations before the scripts are actually loaded.
But there is a scenario where scripts are transpiled on demand, so vscode can't preload their sourcemaps, and can't set breakpoints at the right spots in those scripts until some time after they are loaded. This means that the breakpoints may not be hit, due to the race between running the code and setting the breakpoint at the same time. The best way for vscode to deal with this would be to have node pause execution each time a script is loaded, giving it a chance to load its sourcemaps and set the breakpoint before running the code in the script.
The Chrome devtools protocol for Chrome actually gives us a way to pause execution each time a script is loaded, via https://chromedevtools.github.io/devtools-protocol/1-3/DOMDebugger#method-setEventListenerBreakpoint. But this is in the DOMDebugger domain which doesn't exist in Node.
So what do you think it would take to get an api like this for node as well? Can nodejs implement a subset of the DOMDebugger domain, does a new domain need to be defined? Or maybe someone has an idea for another solution entirely.
The text was updated successfully, but these errors were encountered: