-
Notifications
You must be signed in to change notification settings - Fork 209
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
Integration with node-inspector #225
Comments
Gave this a shot in my global install of nodal. Got up and running by
On a fresh demo project
with
Ran into two problems which I'll have to look at more closely: -When I added a step to install node-inspector, I expected the command to be ignored on my machine since I already have node-inspector installed. But it ran anyway. The better solution is to check if node-inspector is installed, and install it conditionally or something. -Somewhere along the way I interrupted node-inspector's boot up and exited the process. And after that node-inspector stopped opening up a separate chrome instance. I'll have to figure out why. Things to look into next: And easy way to detect if a package is already installed, and if it's not installed, alert the user, or install it. I bet there's an example in the cli directory to follow. What the desired outcome is for node-inspector. Ideally it should open a tab for each process which is running on each port. |
This is a minor issue, but a potential enhancement. npm packages that expose a CLI are typically installed globally.
Folks have pointed out that there are some downsides to the over-use of global NPM dependencies; particularly version management. I think Nodal as a global package falls into the category of appropriate use cases. As I'm looking into integrating npm has long exposed an interface to allow developers to use the CLI exposed by npm modules using a locally installed module. This would be the first time that the relatively clean and simple package.json file would grow to handle a new concern: presenting an interface to the CLI of a locally installed package. Conversely Nodal exposes it's own CLI, so the perhaps better alternative would be to handle this not at the npm script level, but at the Nodal CLI level. |
After some experimenting: Best cleanest option is to just implement the Reduces necessary commands to:
Fires up a nice debugger. Clean. Done. Notes for later discussion: |
Going to but this on the backburner for now. Will figure something out after looking at it more in-depth. |
While this issue is closed, I'd like to use it as a reference for any effort to set up a debugging environment for building Nodal servers. Nodal users are asking for it. Ultimately, there should be a non-worker based startup of the nodal server. The dominant usecase for node-debug is not debugging cluster logic. Latest update is that the instructions in this thread seem to get a debugging session up and running. Here's where the debugger stops: Here's the error message from the console running node-inspector:
|
node-inspector is the default node debugging tool.
Adding support for
node-inspector
is a cool idea.It requires either a new CLI command for starting in debug mode.
Or adding a --debug flag to
nodal s
which instead of runningnode cluster.js
will runnode-inspector cluster.js
The other useful thing would be to figure out if there are some options for
node-inspector
that specify that tabs should be opened on all cluster ports by default.Idea originated from a gitter question; copy/paste here for reference:
Question:
@keithwhor I'm using node-inspector, but when I put a break point in the controllers, node-inspector does not stop. When I put a debugger in the controller, the execution does stop, but node-inspector does not catch it. Do you have any ideas?
Response:
Idea: it depends on how you're starting your nodal server. By default
nodal s
just ends up runningnpm run start
which if you look in yourpackage.json
thenpm start
command just corresponds tonode cluster.js
You'll notice that cluster.js is a little different than a single node process. If your use case is just the default run command, then you're not setting the debugger up to handle just one node process; instead your looking to debug a cluster of processes.See here: node-inspector/node-inspector#130
That issue doesn't resolve the problem, but instead just points at a blog post with some more info here:
https://strongloop.com/strongblog/whats-new-nodejs-v0-12-debugging-clusters/
It's a bit messy, and that blog post pitches some strong-loop tool... but here's the important bit:
...
I gave this a shot with the following:
node-debug cluster.js
http://127.0.0.1:8080/?port=5858
http://127.0.0.1:8080/?port=5859
http://127.0.0.1:8080/?port=5860
http://127.0.0.1:8080/?port=5861
http://127.0.0.1:8080/?port=5862
Or at least that's what did it for me.
I'll open an issue to add a
--debug
flag tonodal s
command that launches nodal using this approach.I think this could explain why you're getting irregular behavior using node-inspector.
The text was updated successfully, but these errors were encountered: