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

New debugger does not attach to process #623

Closed
yuatpocketgems opened this issue Jul 15, 2020 · 17 comments
Closed

New debugger does not attach to process #623

yuatpocketgems opened this issue Jul 15, 2020 · 17 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@yuatpocketgems
Copy link

Describe the bug
Previously we were able to launch a process and have inspector attach to 9229 port and use break points.

On node12 + VSCode 1.47.1, the same setup broke.

  1. Our node process is started with --inspect-brk=0.0.0.0 and in console, the process is stuck at Debugger listening on ws://0.0.0.0:9229/hash
  2. Auto-attach does not attach to 0.0.0.0:9229
  3. Manually attaching via cmd palette fails with connection refused
  4. With an attach configuration, we are able to attach to the process, but break points don't work.
  5. Adding "debug.javascript.usePreview": false does unblock us in the meantime: attaching inspector & breakpointing.

To Reproduce
Steps to reproduce the behavior:

  1. Use node12 + VSCode 1.47 (no babel etc)
  2. Launch a js process
  3. Debugger fails to attach.

Log File
I'm emailing a log file to the email address with this issue's link as reference.

VS Code Version: 1.47.1

Additional context
We do have a hierarchy of indirections before invoking nodemon which might be affecting auto-attach feature.
* In code-workspace, we have launch via npm config
* In node package, we have a script called debug-vscode which calls a bash script
* In the bash script, we start a docker instance
* Then calls docker-compose exec nodemon --inspect-brk=0.0.0.0 ...

@yuatpocketgems yuatpocketgems added the bug Issue identified by VS Code Team member as probable bug label Jul 15, 2020
@connor4312
Copy link
Member

For auto attach: microsoft/vscode#102057 (comment)

With an attach configuration, we are able to attach to the process, but break points don't work.

Can you share a trace log using the instructions from the issue template?

@connor4312 connor4312 added the info-needed Issue requires more information from poster label Jul 15, 2020
@yuatpocketgems
Copy link
Author

yuatpocketgems commented Jul 15, 2020

Two logs, one with autoattach and one without, were sent to connor@xbox.com.

EDIT: Autoattach seems to be attaching to the wrong process (npm in this case) which is on a different port and address than what we specified.

@connor4312
Copy link
Member

Thanks for the logs and context. It seems like you're in the same boat as #586 (comment) -- see that comment for resolution (the nightly build referenced should be available in about 2hrs).

If you need to debug until then you can set debug.javascript.usePreview: false to use the old debugger -- but if things work, please continue using the new one 🙂 (and if they don't, let me know!)

@connor4312 connor4312 added *duplicate Issue identified as a duplicate of another issue(s) and removed bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster labels Jul 15, 2020
@yuatpocketgems
Copy link
Author

yuatpocketgems commented Aug 7, 2020

With debug.javascript.usePreview: false the debugger worked for 1.47.1 and 1.47.2.

It stopped working again on 1.47.3. I believe this is a new issue, and the old issue is not resolved either.

I tried toggle debug.javascript.usePreview to true just now, and the process failed to attach. With the flag on, debugger says it's attached, but breakpoints are not working.

Let me know if you would like more log files.

EDIT: Apologies. The debugger issue has something to do with a jest setting --runInBand, without the flag multiple workers execute files at the same time, possibly messing up break points. Adding the flag back solved the "new problem". Original problem persists however.

@connor4312
Copy link
Member

Thanks for the followup. Can you send a new trace log over?

@yuatpocketgems
Copy link
Author

yuatpocketgems commented Aug 10, 2020 via email

@yuatpocketgems
Copy link
Author

yuatpocketgems commented Aug 10, 2020 via email

@connor4312
Copy link
Member

Attaching logs to mails to Github unfortunately don't come through. Please upload the log by dragging it onto the comment box on github.com, or cc me at connor@xbox.com. Thanks!

@connor4312
Copy link
Member

connor4312 commented Aug 10, 2020

Thanks for the emailed logs!

Up a few weeks ago I linked a solution that involved changing the port: 9229 property to attachSimplePort: 9229. Did that solution not work for you? In the logs you sent I see that it looks like you're using the plain port property.

@yuatpocketgems
Copy link
Author

Tried both attachSimplePort:0 and attachSimplePort:9229. Neither worked. Sending you additional logs.

@connor4312
Copy link
Member

Ah, apologies, missing a step -- the attachSimplePort option was added in the nightly build, so you will need to be on that (or wait until the next VS Code stable release tomorrow or Thursday)

@yuatpocketgems
Copy link
Author

Alright. I tried a couple of configurations and below are some findings.

After switching to nightly build v2020.8.1017, and turning on preview

  • With nodemon --inspect-brk=0.0.0.0

    • a. With attachSimplePort: 9229
      The debugger is able to attach in the initial node execution, then fails at the subsequent executions.
    • b. With attachSimplePort: 0
      The debugger fails to attach.

    It seems like the attachSimplePort flag doesn't work well with custom addresses?

  • With nodemon (without --inspect-brk at all)

    • c. With attachSimplePort: 0 or attachSimplePort: 9229
      Debugger attached ok, but breakpoints failed to work.

Will send logs for c to the email thread.

@connor4312
Copy link
Member

What's the actual command you're running in debug-vscode?

@yuatpocketgems
Copy link
Author

In package.json

  "scripts": {
    ...
    "debug-vscode": "../../../scripts/service-commands.sh `pwd` debug-vscode",
  }

In service-commands.sh

docker-compose exec $containerID \
  nodemon --no-lazy --legacy-watch --inspect-brk=0.0.0.0 --watch ... \
  jest --config=... --runInBand

@connor4312
Copy link
Member

Okay. So you definitely want attachSimplePort: 9229 then.

then fails at the subsequent executions.

How does it fail?

@yuatpocketgems
Copy link
Author

When nodemon sees a change in file, it re-runs jest, then the console gets stuck at

Debugger listening on ws://0.0.0.0:9229/hash
For help, see: https://nodejs.org/en/docs/inspector

@connor4312
Copy link
Member

connor4312 commented Aug 17, 2020

js-debug doesn't support re-attaching when launching a program (without restarting the program). For your scenario I suggest moving your docker launch into a prelaunch task, and then use an "attach" config, e.g.

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "npm",
      "script": "debug-vscode",
      "problemMatcher": [],
      "isBackground": true,
      "label": "npm: debug-vscode",
    }
  ]
}

launch.json

{
  "version": "0.2.0",
  "configurations": [
      {
        "type": "node",
        "request": "attach",
        "name": "Attach",
        "port": 9229,
        "restart": true, // re-attach on reboot
        "preLaunchTask": "npm: debug-vscode", // docker run beforehand
      }
  ]
}

Or, use our remote extensions to work right in the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

2 participants