GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing github.com — inspector: allow --inspect=host:port from js by sam-github · Pull Request #13228 · nodejs/node Conversation
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
technically, there are 2 objects here. the configuration, which can have a getter and setter (or a unified function like I did here), and that actual running listener (if it is running). its not possible to change the port on the fly, the current listener would have only a getter. So, there could be 3 functions... or one, like here, and a warning that the new value won't take effect until a new listener is started. Thoughts?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I am not sure ws should be a singleton.
Implementation-wise we can listen on multiple ports. Also, we were considering a pipe transport in addition to the WS transport for scenarios like subprocesses.
So, maybe expose in API support for multiple "servers"? Then you would start a server on a different port and shutdown the one that was running before.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
this could also be ws.url(), its just a simple ws://host:port/uuid string.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should be just a property
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Would have to be at least a getter (the UUID isn't constant, it changes every time the server socket is closed).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
this URL is long, complex, and chrome specific, which is why I think having a method to insulate us from that is useful. Then again, these URL helpers are sugar, people can always construct the URLs themselves from host, port, UUID. Thoughts?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think this API is not necessary - exactly because the URL can be reconstructed based on parameters.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@eugeneo Am I thinking of it wrong? Would it be useful to have a way to stop the listener thread, then be able to start it again later with the same UUID? Or does it just not matter? I'm not sure what the UUID is supposed to identify, but if its a single still-living instance of the same process, then it should be persistent (debugEnd clears it). If its supposed to identify a specific instance of an agent listening on a TCP port, and change when the port is closed, the current behaviour is fine.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
UUID is there for security, so web sites are not able to connect to Node instances running locally. So it does not represent anything.
It would likely be convinient if it stayed stable over the life of the Node process, but it does not matter much.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for looking into this! I was planning to start a discussion about similar APIs. I believe it would be best to always start WS server from JS code (probably from the node_bootstrap.js). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
(Sorry, thought that button clears the comment field) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this. I think we need some discussion to align the plans for the inspector future.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe ws.listen(waitForFrontend[, host][, port])?
Also, I feel like the agent should always be started from JavaScript - node_bootstrap.js or something can call ws.listen based on command line arguments.
I was planning exposing something like inspector.onDebugSignal(callback) that would allow developers to customize WS server startup - e.g. to start a server on a different port.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
What would the waitForFrontend argument be? What would it do?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It would be a boolean, and it would block the main thread until a debug client connects to the ws port and initiates a session, equivalent to the wait_for_connect boolean option of InspectorIo.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I am not sure ws should be a singleton.
Implementation-wise we can listen on multiple ports. Also, we were considering a pipe transport in addition to the WS transport for scenarios like subprocesses.
So, maybe expose in API support for multiple "servers"? Then you would start a server on a different port and shutdown the one that was running before.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think this API is not necessary - exactly because the URL can be reconstructed based on parameters.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
UUID is there for security, so web sites are not able to connect to Node instances running locally. So it does not represent anything.
It would likely be convinient if it stayed stable over the life of the Node process, but it does not matter much.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I believe there are tests for that. I distinctly remember having to deal with them :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I feel like Ws* bindings should be in the inspector_io.cc.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
UUID may belong to inspector (it now lives pretty much as long as Node
process lives) and become another ctor argument for the io.
Another thing I've been thinking about - what if Inspector WS was a module?
It will still need native code and another thread (as it needs to work
while main thread is paused on a breakpoint) but it could use JS bindings
to talk to the inspector backend.
…On Thu, May 25, 2017 at 7:19 PM Sam Roberts ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lib/inspector.js
<#13228 (comment)>:
> module.exports = {
+ ws: {
+ id: wsId,
+ listen: wsListen,
+ unlisten: process._debugEnd,
+ // XXX find a way to just stop Io thread, not entire agent, so ID can be stable?
@eugeneo <https://github.com/eugeneo> Am I thinking of it wrong? Would it
be useful to have a way to stop the listener thread, then be able to start
it again later with the same UUID? Or does it just not matter? I'm not sure
what the UUID is supposed to identify, but if its a single still-living
instance of the same process, then it should be persistent (debugEnd clears
it). If its supposed to identify a specific instance of an agent listening
on a TCP port, and change when the port is closed, the current behaviour is
fine.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#13228 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARkrT3a1vlPp7WUJMz7E08PN76i-Q25ks5r9ja4gaJpZM4NnGAk>
.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@sam-github - I would start a discussion before landing this - #13247 I am wondering if this server should be separate from the core inspector. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
0b0a3ec to
8d06ca1
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I am very hesitant to do this. If we expose an API for this, then we need to make certain that this cannot be used for anything other than interaction via the Inspector protocol.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It can't be. As is, all this PR does (ATM) is allow instead of forcing --inspect to be provided as a CLI option, it allows node to startup, and then the js API calls the same C++ APIs called to turn on the listener that would have been called if --inspect had been provided. There is zero general purpose protocol or websocket capability exposed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ws.close() is more idiomatic and consistent
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ok. though it sounds like @eugeneo is looking for quite a different API, this is more of a POC at the moment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should just make this a property.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe you think its a single unchanging value? But it isn't, if you run start.js you'll see 2 or 4 values of this UUID printed. So, it could be a getter, but not a fixed-value property.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If there is an existing listener that is bound to a port, what happens?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
right now, nothing, it has no effect (until the listeners is closed and listen is called again).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If introducing new errors, please use internal/errors
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
`ws://${addr()}`
likewise for chromeUrl?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I assume this file wasn't supposed to be checked in?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Its a WIP, this would eventually be test code, but it shows how to call the APIs for now.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
8d06ca1 to
3169ee5
Compare
09cfba7 to
a86f3f5
Compare
PR-URL: nodejs#13228 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]>
a86f3f5 to
2791b36
Compare
|
Marking this as semver-minor post landing. If anyone feels this is incorrect, let me know |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Isn't the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
PR-URL: #13228 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]>
| module.exports = { | ||
| open: (port, host, wait) => open(port, host, !!wait), | ||
| close: process._debugEnd, | ||
| url: url, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Re: #9659 I now think this should have been a URL not a string...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Retrospectively document the changes history of the `inspector.close` API. PR-URL: #44628 Refs: #44489 Refs: #13228 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
Retrospectively document the changes history of the `inspector.close` API. PR-URL: #44628 Refs: #44489 Refs: #13228 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
Retrospectively document the changes history of the `inspector.close` API. PR-URL: #44628 Refs: #44489 Refs: #13228 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
Retrospectively document the changes history of the `inspector.close` API. PR-URL: #44628 Refs: #44489 Refs: #13228 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
Retrospectively document the changes history of the `inspector.close` API. PR-URL: #44628 Refs: #44489 Refs: #13228 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
Retrospectively document the changes history of the `inspector.close` API. PR-URL: #44628 Refs: #44489 Refs: #13228 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
Retrospectively document the changes history of the `inspector.close` API. PR-URL: nodejs/node#44628 Refs: nodejs/node#44489 Refs: nodejs/node#13228 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
Retrospectively document the changes history of the `inspector.close` API. PR-URL: nodejs/node#44628 Refs: nodejs/node#44489 Refs: nodejs/node#13228 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.