Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alloy/a9050e7500ce4a3cc25a23f85358b491 to your computer and use it in GitHub Desktop.
Save alloy/a9050e7500ce4a3cc25a23f85358b491 to your computer and use it in GitHub Desktop.

First grep the heroku logs for the message that will state that the debugger service has started:

$ heroku logs -t --app=[APP_ID] | grep 'Debugger listening on'

Then in another shell enable the debugger service of the Node process by connecting through SSH and sending the process SIGUSR1:

$ heroku ps:exec --app=[APP_ID]
Establishing credentials... done
Connecting to web.1 on ⬢ [APP_ID]
$ ps aux | grep node
u46040       4  0.8  0.0 987944 38544 ?        Sl   14:53   0:00 node node_modules/.bin/forever -c node --max_old_space_size=960 build/index.js
u46040      27  0.0  0.0  18168  2464 ?        S    14:53   0:00 bash --login -c node_modules/.bin/forever -c "node --max_old_space_size=960" build/index.js
u46040      60  7.8  0.1 1320688 106020 ?      Sl   14:53   0:07 node --max_old_space_size=960 /app/build/index.js
u46040      75  0.0  0.0   8880   772 pts/0    S+   14:55   0:00 grep node
$ kill -s USR1 60

Back in the shell where the heroku logs are being grepped, it should now show something like:

2018-02-16T14:56:08.233521+00:00 app[web.1]: Debugger listening on ws://127.0.0.1:9229/bc540eda-30fd-4023-8474-1a8dfe4faf41

You can now kill the logging process and start forwarding the remote debugger service’s port to your local machine:

$ heroku ps:forward 9229 --app=[APP_ID]
Establishing credentials... done
SOCKSv5 proxy server started on port 1080
Listening on 9229 and forwarding to web.1:9229
Use CTRL+C to stop port fowarding

Once that’s up and running, open Chrome and navigate to chrome://inspect. Under the Remote Target heading you should now see the process, which you can start debugging by clicking the ‘Inspect’ link.

When you’re finished debugging, it’s probably a good idea to restart the heroku process, I haven’t done any inspecting of the negative impact of leaving the debugger service running, but it probably has some impact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment