Kevv Keka
Kevv Keka

Reputation: 314

Heroku | Node.js | Exception when debugging remotely

I have express.js REST API server on Heroku.

I am trying to debug an error remotely. But, I receive below exception. The steps I tried to debug remote server are mentioned after this exception section.

Can someone please help me how can I debug remote node.js/express.js server?

The exception I receive:

events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: connection not allowed by ruleset
    at Parser._onData (/usr/local/Cellar/heroku/7.47.11/lib/client/7.59.1/node_modules/@heroku/socksv5/lib/client.parser.js:122:21)
    at Socket.Parser.__onData (/usr/local/Cellar/heroku/7.47.11/lib/client/7.59.1/node_modules/@heroku/socksv5/lib/client.parser.js:33:10)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Emitted 'error' event on Client instance at:
    at Parser.<anonymous> (/usr/local/Cellar/heroku/7.47.11/lib/client/7.59.1/node_modules/@heroku/socksv5/lib/client.js:132:10)
    at Parser.emit (events.js:314:20)
    at Parser._onData (/usr/local/Cellar/heroku/7.47.11/lib/client/7.59.1/node_modules/@heroku/socksv5/lib/client.parser.js:126:16)
    at Socket.Parser.__onData (/usr/local/Cellar/heroku/7.47.11/lib/client/7.59.1/node_modules/@heroku/socksv5/lib/client.parser.js:33:10)
    [... lines matching original stack trace ...]
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
  code: 'EACCES'
}

This is what I am trying:

  1. On my local Terminal, I run heroku ps:forward 9229 --app MY_EXPRESS_APP command.
  2. On my local Visual Code, I have the below launch.json configuration. I tried with both the configurations mentioned in it. (I understand I need only one. But I checked other Stackoverflow articles. So, I tried both the suggestions).
    "configurations": [
        {
            "address": "TCP/IP address of process to be debugged",
            "localRoot": "${workspaceFolder}",
            "name": "ONE: Attach to Remote",
            "port": 9229,
            "remoteRoot": "/app",
            "request": "attach",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "node"
        },
        {
            "type": "node",
            "request": "attach",
            "name": "TWO: Remote Heroku: Debug Remote Server",
            "address": "localhost",
            "port": 9229,
            "protocol": "inspector",
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/app"
        }
    ]
  1. I try to run below command. When I start Debug with above one of configuration... the debugger tries to connect and pauses. And, after 2 or 3 minutes, I see the above exception on Terminal under this command.
$ heroku ps:forward 9229 --app MY_EXPRESS_APP
heroku ps:forward 9229 --app MY_EXPRESS_APP
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

Upvotes: 2

Views: 170

Answers (1)

AlexAngc
AlexAngc

Reputation: 341

One cause for this error to happen is the CPU being overloaded or throttled.

On an old Windows 10 laptop in which I configured the energy settings to throttle my CPU to 60% (to prevent overheating), the error was reliably happening less than one minute after starting a snapshot. After removing this throttling setting (max CPU usage in advanced power settings), I was able to snapshot the heap with a 95% success rate.

I suggest the following:

  • Make sure your CPU isn't throttled by any energy saving policy;
  • Decrease the priority of the Chrome processes (in task managers, details tab. The snapshot task takes a lot of CPU power);
  • Increase the process priority of the shell running heroku ps:forward ....
  • Temporarily disable the Antimalware Service Executable;

Upvotes: 0

Related Questions