Skip to Content
0
Dec 07, 2022 at 03:30 AM

Set Up Remote Debugging to Diagnose CAP Applications (Node.js Stack) on SAP BTP CF

1127 Views Last edit Dec 15, 2022 at 08:53 AM 4 rev

Hello everyone,
I would like to debug a backend-side (Node.js) running on SAP BTP using SAP BAS.

I've followed Set Up Remote Debugging to Diagnose CAP Applications (Node.js Stack) at Runtime Running on SAP BTP, Cloud Foundry Environment and have couple of questions

1. After Step 4: Enable the Node.js Inspector for Remote Debugging on a Running Application Instance, There I couldn't find exact node /home/vcap/deps/0/bin/npx cds run rather

user: remotetestapp $ cf ssh remotetestapp-srv
vcap@36cc5bb8-1a96-413a-7756-a942:~$ ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   1112     4 ?        Ss   05:24   0:00 /tmp/garden-init
vcap           7  1.8  0.0 801996 73584 ?        Ssl  05:24   0:00 npm start
vcap          13  0.0  0.0 724192  9860 ?        Ssl  05:24   0:00 /tmp/lifecycle/diego-sshd --allowedKeyExchanges= --address=0.0.0.0:
root          21  0.0  0.0   4640   856 ?        Ss   05:24   0:00 sh -c trap 'kill -9 0' TERM; /etc/cf-assets/envoy/envoy -c /etc/cf-
root          86  0.6  0.0 2759492 52416 ?       Sl   05:24   0:00 /etc/cf-assets/envoy/envoy -c /etc/cf-assets/envoy_config/envoy.yam
vcap         186  0.0  0.0   4644   836 ?        S    05:24   0:00 sh /home/vcap/tmp/start-6e172f3b.sh
vcap         187  2.7  0.0 11225584 94108 ?      Sl   05:24   0:00 node /home/vcap/app/node_modules/.bin/cds run
root         198  0.0  0.0 714632  4216 ?        Ssl  05:24   0:00 /etc/cf-assets/healthcheck/healthcheck -port=8080 -timeout=1000ms -
vcap         209  0.0  0.0  70392  3768 pts/0    Ss   05:24   0:00 /bin/bash
vcap         220  0.0  0.0  86288  3348 pts/0    R+   05:25   0:00 ps aux

Although I continue by killing PID 187, then followed port forwarding
PFB attached Log

btp-log.png

2. After successful Port forwarding, I cant find the source code and process.env.ADDR =undefined
launch.json :

    {<br>      "name": "Attach to a Cloud Foundry Instance on Port 9229",<br>      "port": 9229,<br>      "request": "attach",<br>      "type": "node",<br>      "localRoot": "${workspaceFolder}",<br>      "remoteRoot": "/home/vcap/app"<br>    }

Terminal:

terminal.png

[cds] - using auth strategy: {kind: 'xsuaa'} 

cds.version
'6.3.2'
process.ppid
186
process.env.ADDR
undefined<br>


Same in case of Chrome Devtools, The Remote Target was Blank and can't interact with the REPL.
PFA Image

chromedevtool.png

connection.png


image.png


Please help in fixing the issue, your feedback is appreciated

Thanks
Pravin

Attachments

btp-log.png (84.5 kB)
terminal.png (69.4 kB)
chromedevtool.png (44.5 kB)
connection.png (52.4 kB)
image.png (47.8 kB)