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

About vscode debugging #62

Open
CeccoCQ opened this issue Aug 8, 2019 · 3 comments
Open

About vscode debugging #62

CeccoCQ opened this issue Aug 8, 2019 · 3 comments
Labels

Comments

@CeccoCQ
Copy link

CeccoCQ commented Aug 8, 2019

Maybe I'm too newbie with Vscode, but I don't understand at all how can I debug this nodejs app in a total way.

If I would to start the docker container with docker-compose up then try to debug www file, for example, I'm not able to do it.
So, I've some questions:

  • Is there a way to launch the container in a debug mode at the start?
  • When I change a file, the nodemon detects changes and restart node server. I've to re-attach my debug, is it right or I've missing something?
  • Why some statement aren't debuggable? For example into the healthcheck.js I've always unverified breakpoints or into index.js (see attachment).

Schermata 2019-08-08 alle 09 10 41

@BretFisher
Copy link
Owner

Did you figure this out? I didn't have time lately to look into this.

@BretFisher
Copy link
Owner

Some quick answers without testing:

  1. --inspect is on by default in the docker-compose.yml. I guess you're asking about VS Code turning on debugging by default, and I'm not sure.
  2. That sounds right. Node is stopped and restarted, so VS Code may not auto-reconnect to inspector port. There might be a VS Code setting to do that.
  3. Not sure exactly. VS Code can be tricky in the launch.json settings sometimes. Note that healthcheck.js isn't running by the same process that's running that app, so it won't be debuggable by VS Code using the existing launch.json. It's run by the Dockerfile HEALTHCHECK command which runs a separate node process via docker exec. To debug that, you'd need to enable --inspect option in that HEALTHCHECK command, but the exec won't publish the ports, so debugging it would require a more creative solution.

@outbits
Copy link
Contributor

outbits commented Jun 22, 2021

Hello,

  • To address 1 and 3, --inspect-brk is what you may be looking for as it starts a debugging session before user code is executed, while the current --inspect in the compose config attaches after the server finishes setting up which is why something like const app = express() isn't debuggable.
  • As for 2, adding restart: true to launch.json's debug port config will do what you're looking for

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

No branches or pull requests

3 participants