-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Add v8_inspector support #6792
Add v8_inspector support #6792
Conversation
@@ -0,0 +1,2 @@ | |||
# v8_inspector | |||
# v8_inspector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful README is Useful ;-)
Awesome! Thanks everyone that helped put all this together and made it possible! |
@ofrobots I'm a bit late to the party so sorry if this has been covered in the other thread... Would this PR landing change anything in regards to the current debugger? |
Great to see this come through. Looking forward to playing around with it. |
@thealphanerd The old debugger is not affected, and still works as-is. |
My initial reaction is that this is fantastic. Thank you. |
It would be great if it could be enabled/disabled at runtime using a v8.debugOn/Off() js API call. |
@ofrobots Why import the entire inspector? |
Was wondering that myself... |
What do you mean by entire inspector?
Does present debugger allow that? We were aiming at feature parity before we start adding features. Enabling dynamically means that we would bind port at runtime. Other than that, debugger can be enabled/disabled at any moment, no technical limitations there. |
Nice work! So the intent is for this to get merged to v6 and then removed again at v7 when it's baked into V8? Why not just wait until v7 when it's built-in? Certainly it's valuable work and would benefit v6 greatly, but this is a rather large chunk of stuff to review only to remove it again in a few months. What does the plan look like for merging with V8? I assume the user-facing surface of it would stay the same when we reach v7? (Other than maybe not needing the build flag anymore?) |
The second commit -> a7f339b |
This PR is not bringing in the DevTools inspector. It only brings in the v8_inspector part, which is an implementation of the DevTools debug protocol.
This would be a good follow-on. Once this PR lands, it would be easier to work on the ergonomics & integration.
The review is needed on 0995140. This integrates the inspector protocol into Node-core. This code is is not going to be removed in a few months. Once this is reviewed and merged, it would be an independent question whether this should merge into v6.x. Part of the answer depends on whether this is a semver major change. The other, larger, commit is a dependency that is needed until the dependency merges upstream into V8. Here's the upstream repository: https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/v8_inspector/. This commit, like other dependency rolls, doesn't really need an in-depth review. EDIT: fix link. |
Thanks so much for all this work! Really looking forward to having a "real"/modern debugger protocol for node. I assume that since the The above ("what will become the next LTS") is also, imo, a good reason for bringing it into node 6 and to not wait until all the inspector pieces landed in v8 itself. |
Hmmm, when we were originally discussing this I was under the impression we'd only have the hooks for the v8 debugger but not actually ship the v8 debugger? IIRC the v8 (chrome?) debugger is very version agnostic so there wasn't any great need for it to ship in core, and shipping in core is pretty awkward as we see with npm. e.g. you're never quite on the version you want to be. Plus it's a ton of extra source code. This is assuming the v8/chrome debugger doesn't need native compilation, if it does, that is probably going to be a whole other issue. Another question: is this intending to replace the default node debugger? |
This PR does not include the Devtools debugger. It only includes the debugger protocol implementation. When you run with
Chrome will load the version of inspector identified by the id, served from the DevTools web hosts. The only thing Node is doing, is implementing a debug server that 'talks' the protocol expected by the Devtools debugger.
No. |
Wow, I'm really surprised that it is this large given that it's just the hooks... |
Ok, so it's the hooks + the protocol, that makes sense. Will have to spend some time digging into that second commit. The size is a bit concerning but not too bad. |
BTW, there are other debuggers that already talk the same protocol, for example: https://github.com/Microsoft/vscode-chrome-debug. It is conceivable that these debuggers could be extended to support Node.js debugging. |
Sorry, I was a bit vague. I meant to ask specifically about if the dependency would get removed in v7 (due to being integrated in V8). Merging 0995140 seems reasonable to me. It's just a7f339b that I'm a bit wary of, since it'd be a bunch of churn to add it and then remove it again. Am I understanding the plan right? The dep get added in v6, then hopefully merged into V8 and removed again for probably v7? |
FWIW, I'm leaning more toward just merging it for the sake of making debugging in v6 LTS much nicer. I'm just a bit unsure of the semver-minor-ness of this and the extra work to pull the dep in and maintain it, if we already know we're going to need to remove it again later and get it through the V8 dep. |
@ofrobots ... are the jinja and markupsafe dependencies really necessary? What are those being used for? (I could keep digging and find out but figured it would be easier to ask ;-) ..) |
If there is push back on a7f339b due to size, could it be brought in similar to the way we were handling icu before? |
those are build-time dependencies, we are using jinja to generate native protocol dispatcher and protocol data structures off protocol.json. |
I'll be using --inspect from nodejs/node#6792
I cant print to chrome console on Windows. Macbook works fine. Anyone else having this issue? |
how to autostart chrome devtool when i write |
@uMaxmaxmaximus I use this Chrome extension: https://chrome.google.com/webstore/detail/nodejs-v8-inspector/lfnddfpljnhbneopljflpombpnkfhggl |
Extention throw error:
|
@uMaxmaxmaximus Sorry, I am not the author of that extension and I don't think this is a right place to try to solve the issue ... https://github.com/continuationlabs/node-v8-inspector |
@FredyC Maybe link active debugger put to global.debug = {
url: 'bla bla',
port: 'bla bla',
next: function(){ [native code] },
stepInto: function(){ [native code] },
e.t.c
} |
@uMaxmaxmaximus I don't know, it works for me (on Windows as well). There is another alternative you might try ... https://github.com/jaridmargolin/inspect-process |
@uMaxmaxmaximus http://june07.com/nim will manage DevTools (including auto launch). |
Hi @ofrobots and team. Can we debug Node.js code written in TypeScript (.ts file) rather than regular JS? |
@alysson-pina it should not matter as long as V8 can run the code. One thing you may need is to generate in-line source maps. |
Thanks Eugene.
I'm asking it because when I'm running it to debug a .ts file, it errors
out with a SyntaxError saying "SyntaxError: Unexpected token import".
Seems that it doesn't support TypeScript, as my app runs fine normally.
…On Wed, Mar 29, 2017 at 5:31 PM, Eugene Ostroukhov ***@***.*** > wrote:
@alysson-pina <https://github.com/alysson-pina> it should not matter as
long as V8 can run the code. One thing you may need is to generate in-line
source maps.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6792 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEGIeRqZrDZLVMY11md771nvbh34-b66ks5rqr-wgaJpZM4IfrJC>
.
|
Where do you see the error? How do you run the Node to debug TypeScript? |
I see it on command line when running it via: "node --inspect server.ts"
Error:
"Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=
127.0.0.1:9229/d1ae07ab-70fc-48bc-a39b-39e8fd0c4af0
.../src/server/server.ts:1
(function (exports, require, module, __filename, __dirname) { import * as
http from "http";
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
Waiting for the debugger to disconnect...
Debugger attached."
…On Wed, Mar 29, 2017 at 7:31 PM, Eugene Ostroukhov ***@***.*** > wrote:
Where do you see the error? How do you run the Node to debug TypeScript?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6792 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEGIeaUQagjZBBVOuDcAf9oCW7cFzDFIks5rqtvVgaJpZM4IfrJC>
.
|
Node cannot run TypeScript directly - e.g. "node server.ts" will fail just
the same. You need to debug compiled code.
…On Wed, Mar 29, 2017 at 3:37 PM Alysson ***@***.***> wrote:
I see it on command line when running it via: "node --inspect server.ts"
Error:
"Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
***@***.***/inspector.html?experiments=true&v8only=true&ws=
127.0.0.1:9229/d1ae07ab-70fc-48bc-a39b-39e8fd0c4af0
/Users/alysson/repo/AC/spyglass/spyglass-server/src/server/server.ts:1
(function (exports, require, module, __filename, __dirname) { import * as
http from "http";
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
Waiting for the debugger to disconnect...
Debugger attached."
On Wed, Mar 29, 2017 at 7:31 PM, Eugene Ostroukhov <
***@***.***
> wrote:
> Where do you see the error? How do you run the Node to debug TypeScript?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#6792 (comment)>, or
mute
> the thread
> <
https://github.com/notifications/unsubscribe-auth/AEGIeaUQagjZBBVOuDcAf9oCW7cFzDFIks5rqtvVgaJpZM4IfrJC
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6792 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AARkrdEFqMy5gPrXdHS3KegpNgzfM01lks5rqt0sgaJpZM4IfrJC>
.
|
Good call. Definitely must be it then. Thanks a bunch Eugene =)
On Wed, Mar 29, 2017 at 7:41 PM, Eugene Ostroukhov <notifications@github.com
… wrote:
Node cannot run TypeScript directly - e.g. "node server.ts" will fail just
the same. You need to debug compiled code.
On Wed, Mar 29, 2017 at 3:37 PM Alysson ***@***.***> wrote:
> I see it on command line when running it via: "node --inspect server.ts"
>
> Error:
>
> "Debugger listening on port 9229.
> Warning: This is an experimental feature and could change at any time.
> To start debugging, open the following URL in Chrome:
>
>
> chrome-devtools://devtools/remote/serve_file/@
60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?
experiments=true&v8only=true&ws=
> 127.0.0.1:9229/d1ae07ab-70fc-48bc-a39b-39e8fd0c4af0
> /Users/alysson/repo/AC/spyglass/spyglass-server/src/server/server.ts:1
> (function (exports, require, module, __filename, __dirname) { import * as
> http from "http";
> ^^^^^^
> SyntaxError: Unexpected token import
> at Object.exports.runInThisContext (vm.js:76:16)
> at Module._compile (module.js:542:28)
> at Object.Module._extensions..js (module.js:579:10)
> at Module.load (module.js:487:32)
> at tryModuleLoad (module.js:446:12)
> at Function.Module._load (module.js:438:3)
> at Module.runMain (module.js:604:10)
> at run (bootstrap_node.js:394:7)
> at startup (bootstrap_node.js:149:9)
> at bootstrap_node.js:509:3
> Waiting for the debugger to disconnect...
> Debugger attached."
>
> On Wed, Mar 29, 2017 at 7:31 PM, Eugene Ostroukhov <
> ***@***.***
> > wrote:
>
> > Where do you see the error? How do you run the Node to debug
TypeScript?
> >
> > —
> > You are receiving this because you were mentioned.
> > Reply to this email directly, view it on GitHub
> > <#6792 (comment)>, or
> mute
> > the thread
> > <
> https://github.com/notifications/unsubscribe-auth/
AEGIeaUQagjZBBVOuDcAf9oCW7cFzDFIks5rqtvVgaJpZM4IfrJC
> >
> > .
> >
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#6792 (comment)>, or
mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/
AARkrdEFqMy5gPrXdHS3KegpNgzfM01lks5rqt0sgaJpZM4IfrJC>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6792 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEGIefZo7WYHNwpcWnbx0XIyQrQFR2Uwks5rqt4bgaJpZM4IfrJC>
.
|
So the final conclusion is that there is no way to debug node written in TypeScript? |
@rafraph This is probably not the place to ask how to debug TypeScript. Lookup Debugging with Source Maps, I'm sure there are lots of tutorials. If you get stuck, ask on https://StackOverflow.com |
I'm not asking how to debug typescript. From reading this thread it seems that debugging node written in TypeScript is not supported in Chrome. After @alysson-pina asked his question, it seems from the answers that this is not supported, so I just want to know if this is the final conclusion. |
Hey Refael,
so my answer would be yes and no. You can't directly debug node code
written in Typescript.
However you can debug the transpiled JS code just the same. =)
…On Thu, Apr 27, 2017 at 8:48 AM, Refael Jan ***@***.***> wrote:
I'm not asking how to debug typescript. From reading this thread it seems
that debugging node written in TypeScript is not supported in Chrome. After
@alysson-pina <https://github.com/alysson-pina> asked his question, it
seems from the answers that this is not supported, so I just want to know
if this is the final conclusion.
BTW, I asked it in StackOverflow.com and someone send me to here, so this
is an infinite loop :-)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6792 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEGIefcGdcHfZoYvm-nJs-sTQdjKOioMks5r0IB8gaJpZM4IfrJC>
.
|
What do you mean by "the same"? the traspiled code is totaly different and not really readable. |
@rafraph And that's where source maps comes in :) #6792 (comment) |
Is it true that live debug is impossible with this feature? I mean, debug an app with Currently Chrome Devtools breaks down when I save changes in my app: How to deal with it? How to make Devtools reconnect automatically? |
Open chrome://inspect. There click "Open dedicated DevTools for Node" -
that instance should be able to reconnect (and it will also connect
automatically when you start Node)
…On Mon, Jan 15, 2018 at 11:20 AM wzup ***@***.***> wrote:
Is it true that live debug is impossible with this feature? I mean, debug
an app with nodemon, for example, when nodemon restarts the server on
every save Ctrl + S?
Currently Chrome Devtools breaks down when I save changes in my app:
[image: dev tools]
<https://user-images.githubusercontent.com/3880497/34958260-be061126-fa39-11e7-8f82-11f71015e361.png>
How to deal with it? How to make Devtools reconnect automatically?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6792 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AARkreQIXQrbUKCyE5_hGD4ApNBccKaYks5tK6URgaJpZM4IfrJC>
.
|
For background see: #2546 (comment)
This PR brings in v8_inspector support to Node.js (currently behind a compile time flag.) This means Node.js can now be debugged and profiled via the Chrome Debugging Protocol, which enables inspection via Chrome DevTools and other tools & IDEs. So far, v8_inspector includes support for the following protocol domains: Debugger, Profiler, Runtime, HeapProfiler
In the Chrome DevTools client, the following is now available:
There is more functionality that could be implemented, but we've reached a good point to get input from the community on the feature set and on the integration with Node.js core.
This PR has two logical sets of changes:
Bring in v8_inspector as a dependency
v8_inspector
used to be part of Blink. We have removed almost all of the dependencies on Blink and are working on getting this code merged directly into V8 – the biggest piece remaining is integrating the DevTools tests into the V8 test infrastructure. However, this work will likely complete in V8 5.3 / 5.4 timeframe. If we wait for this upstream change, it would mean the improved debugging experience would not be available to Node.js v6.x LTS users.In the meantime, we propose to bring the v8_inspector dependency directly into Node.js. This dependency can be dropped once v8_inspector merges upstream into V8 (in Node.js v7.x timeframe).
Node.js support for the v8_inspector protocol
The support for talking to v8_inspector protocol is primarily in
node_inspector.cc
. We also needed support for a subset of the websockets protocol to be able to talk to DevTools. We have implemented this based on the websockets implementation from Chromium. We are calling it the 'inspector socket protocol' as it is not a complete websockets implementation, although it could be extended. This protocol is not available to userspace JavaScript code, and is accessible only to internal C++ code in core.The implementation is behind a compile time flag controlled by the
--with-inspector
configure flag.Usage
You can attach Chrome DevTools by opening the printed url in a Chrome browser.
By default, the debugging port is 5858. You can optionally specify an alternate port via the
--inspect=9229
flag. If you want the debugger to pause on application start, you can additional pass the--debug-brk
flag. For example:Getting this merged into Node.js would allow people to test the DevTools integration and allow proper debugging to be well-tested and stable well in time for the release of the 6.x LTS. It would also enable third-party debug tool writers to start building other debugging and profiling tools that work with Node.js.
Thanks for the review.
/cc @repenaxa, @eugeneo, @paulirish