Skip to content
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

anyone tried --inspect with socketcluster #204

Closed
cometta opened this issue Jul 26, 2016 · 7 comments
Closed

anyone tried --inspect with socketcluster #204

cometta opened this issue Jul 26, 2016 · 7 comments

Comments

@cometta
Copy link

cometta commented Jul 26, 2016

I unable to run node --inspect with socketcluster .

$node --inspect ./server.babel.js
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/@521e5b7e2b7cc66b4006a8a54cb9c4e57494a5ef/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node
Debugger listening on port 5859.
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/@521e5b7e2b7cc66b4006a8a54cb9c4e57494a5ef/inspector.html?experiments=true&v8only=true&ws=localhost:5859/node
[Busy] Launching SocketCluster
Unable to open devtools socket: address already in use
1: node::Abort() [/usr/local/bin/node]
2: node::inspector::AgentImpl::WorkerRunIO() [/usr/local/bin/node]
3: uv__thread_start [/usr/local/bin/node]
4: _pthread_body [/usr/lib/system/libsystem_pthread.dylib]
5: _pthread_body [/usr/lib/system/libsystem_pthread.dylib]
6: thread_start [/usr/lib/system/libsystem_pthread.dylib]

@mattkrick
Copy link
Contributor

Heh, fun, I got a different callstack though:

   [Error] Error: scBroker server at socket path /var/folders/r_/sxm2m5wj5zl0k_z_6pczzydc0000gn/T/socketcluster/Action_cc2b3cba44/b0 exited
    at EventEmitter.<anonymous> (/Users/mk/Code/action2/node_modules/sc-broker-cluster/index.js:352:19)
    at emitTwo (events.js:106:13)
    at EventEmitter.emit (events.js:191:7)
    at EventEmitter.emit (/Users/mk/Code/action2/node_modules/sc-domain/index.js:12:31)
    at ChildProcess.<anonymous> (/Users/mk/Code/action2/node_modules/sc-broker/index.js:77:10)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at ChildProcess.EventEmitter.emit (/Users/mk/Code/action2/node_modules/sc-domain/index.js:12:31)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)

@jondubois this is a gamechanger if we can get this to work, any ideas on where to start?
Must be at least node v6.3.0, I'm running v6.4.0

@jondubois
Copy link
Member

jondubois commented Aug 21, 2016

@cometta @mattkrick Ok I implemented the fix in v5.0.9. Note that if you use the --inspect flag like node --inspect server; that will debug the master process (server.js).

If you want to debug workers, you need to add an --inspect-workers flag AFTER the server argument like this:

node server --inspect-workers

You can also debug broker processes using --inspect-brokers like this:

node server --inspect-brokers

I've updated the docs here http://socketcluster.io/#!/docs/debugging with info about the --inspect flag.

Note that there is currently a minor 'bug' in Node.js which prevents you from setting custom debug ports for the workers when using the --inspect-workers=${startingPort} flag. This is should not be a problem if you are happy to use the default ports.

I raised an issue on the Node.js repo: nodejs/node#8201

@mattkrick
Copy link
Contributor

Still getting something weird:

> NODE_ENV=development node ./src/server/server.babel.js --inspect-workers

   [Busy] Launching SocketCluster
   >> Broker PID: 52206
Debugger listening on port 5858.
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/@62cd277117e6f8ec53e31b1be58290a6f7ab42ef/inspector.html?experiments=true&v8only=true&ws=localhost:5858/node
Debugger listening on port 5859.
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/@62cd277117e6f8ec53e31b1be58290a6f7ab42ef/inspector.html?experiments=true&v8only=true&ws=localhost:5859/node
Creating a pool connected to localhost:28015
   >> Worker PID: 52208
   [Active] SocketCluster started
            Version: 5.0.9
            WebSocket engine: uws
            Port: 3000
            Master PID: 52205
            Worker count: 1
            Broker count: 1

Unable to open devtools socket: address already in use
Unable to open devtools socket: address already in use
Unable to open devtools socket: address already in use
1471749078806 - Origin: Worker (PID 52208)
   [Error] Error: channel closed
    at ChildProcess.target.send (internal/child_process.js:523:16)
    at Object.HappyThread.configure (/Users/mk/Code/action2/node_modules/happypack/lib/HappyThread.js:74:10)
    at /Users/mk/Code/action2/node_modules/happypack/lib/HappyThreadPool.js:39:18
    at /Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:713:13
    at async.forEachOf.async.eachOf (/Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:233:13)
    at _parallel (/Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:712:9)
    at Object.async.parallel (/Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:726:9)
    at Object.HappyThreadPool.configure (/Users/mk/Code/action2/node_modules/happypack/lib/HappyThreadPool.js:37:13)
    at /Users/mk/Code/action2/node_modules/happypack/lib/HappyPlugin.js:226:25
    at /Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:721:13
    at /Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:52:16
    at done (/Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:241:17)
    at /Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:44:16
    at /Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:718:17
    at /Users/mk/Code/action2/node_modules/happypack/node_modules/async/lib/async.js:167:37
    at /Users/mk/Code/action2/node_modules/happypack/lib/fnOnce.js:7:17
    at ChildProcess.<anonymous> (/Users/mk/Code/action2/node_modules/happypack/lib/HappyThread.js:22:11)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at ChildProcess.EventEmitter.emit (/Users/mk/Code/action2/node_modules/sc-domain/index.js:12:31)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
Unable to open devtools socket: address already in use
1471749078916 - Worker 0 exited - Exit code: 1
Debugger listening on port 5860.
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/@62cd277117e6f8ec53e31b1be58290a6f7ab42ef/inspector.html?experiments=true&v8only=true&ws=localhost:5860/node

@jondubois
Copy link
Member

@mattkrick You need to update dependencies too:

  • sc-broker v2.2.2
  • sc-broker-cluster v2.1.4

@cometta
Copy link
Author

cometta commented Sep 1, 2016

I tested this working fine now. May i know when we view the sourcemap , source file in chrome dev tool, it showed the babel transpiled code instead of raw es6 code. How to display es6 code in dev tool sourcemap?

@jondubois
Copy link
Member

Note that recently there was a similar issue related to using the top-level --inspect flag to debug the master process. This has been fixed in socketcluster v9.3.3.

@marcj
Copy link

marcj commented Oct 16, 2018

Note: This does not work with ts-node, only with ts-node-dev.

So

node_modules/.bin/ts-node src/main.ts --inspect-workers

would not work. Just use the ts-node-dev package.

node_modules/.bin/ts-node-dev src/main.ts --inspect-workers

and it prints something like

Debugger listening on ws://127.0.0.1:5858/b2894045-ca5d-4b8a-ac3f-2594e980f655
For help, see: https://nodejs.org/en/docs/inspector
Debugger listening on ws://127.0.0.1:5859/a9193138-6e08-4c79-b3c1-980434a6a257
For help, see: https://nodejs.org/en/docs/inspector

which indicates it opened the debugging ports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants