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

[Regression] Debugging of typescript node apps has been broken #40430

Closed
Deilan opened this issue Dec 18, 2017 · 4 comments
Closed

[Regression] Debugging of typescript node apps has been broken #40430

Deilan opened this issue Dec 18, 2017 · 4 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues info-needed Issue requires more information from poster

Comments

@Deilan
Copy link

Deilan commented Dec 18, 2017

  • VSCode Version:
    Code 1.19.0 (816be67, 2017-12-14T12:06:43.492Z)
    Code - Insiders 1.20.0-insider (08ec160, 2017-12-
    15T05:15:38.886Z)
  • OS Version: Windows_NT x64 10.0.16299
  • Extensions: none

Debugging works fine in Code 1.18.1 (929bacb, 2017-11-16T18:32:36.023Z). Have to revert to it until the bug is fixed.

Steps to Reproduce:

  1. clone https://github.com/deilan/node-typescript-vscode
  2. npm install or yarn install
  3. Launch Launch via nodemon debugging configuration

Result:
The process has been started, debugger couldn't start with the following error message:

Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:35247).

@vscodebot vscodebot bot added the debug Debug viewlet, configurations, breakpoints, adapter issues label Dec 18, 2017
@isidorn isidorn assigned weinand and unassigned isidorn Dec 18, 2017
@weinand
Copy link
Contributor

weinand commented Dec 18, 2017

Your launch config is wrong (and it was only working in previous versions of VS Code because of bug #16173).
The problem is that you are passing all arguments via the "runtimeArgs" attribute. This makes it difficult for VS Code to insert the "--inspect-brk" argument it the right location.

Instead you should only pass nodemon arguments via "runtimeArgs", then use the "program" attribute for your "real" program and then the "real" arguments through the "args" attribute.
(So if you remove the "runtimeExecutable" and "runtimeArgs" attributes from the launch config, then you should end up with a launch config that runs your program without nodemon.)
E.g.:

{
    "name": "Launch via nodemon",
    "type": "node",
    "request": "launch",
    "protocol": "inspector",
    "cwd": "${workspaceRoot}",
    "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon",
    "runtimeArgs": [
        "--exitcrash",
        "--config", "${workspaceRoot}/nodemon.json",
        "--exec", "${workspaceRoot}/node_modules/.bin/ts-node",
    ],
    "program": "${workspaceRoot}/src/index.ts",
    "args": [
        "--project", "${workspaceRoot}/tsconfig.development.json"
    ],
    "restart": true,
    "console": "integratedTerminal",
    "internalConsoleOptions": "openOnSessionStart",
    "skipFiles": [
        "node_modules/**",
        "<node_internals>/**"
    ]
},

This launch config should work on all versions of VS Code so you can try it with 1.18.1 and if it works you can safely upgrade to 1.19.

Let me know if this works.

@weinand weinand added the info-needed Issue requires more information from poster label Dec 18, 2017
@Deilan
Copy link
Author

Deilan commented Dec 18, 2017

@weinand Thanks for the explanation. I've tried the suggested debug configuration. Unfortunately I've got the following error message on both 1.18.1 and 1.20.0:

Cannot launch program 'c:\Dev\node-typescript-vscode\src\index.ts' because corresponding JavaScript cannot be found.

There's no outFiles and as far as I understand specifying them doesn't make sense. Of course if I specify outFiles as an empty array I get:

Cannot launch program 'c:\Dev\node-typescript-vscode\src\index.ts' because corresponding JavaScript cannot be found.

@weinand
Copy link
Contributor

weinand commented Dec 18, 2017

You do not seem to have an explicit build task that transpiles TS to JS.
The ts-node seems to be the tool that transpiles in your case.
That means VS Code cannot really know where the generated JS lives.
But since ts-node takes care of it, VS Code does not really has to know.

Remove the "program" attribute and insert the "${workspaceRoot}/src/index.ts" as the first argument of the "args" attribute just before "--project".

{
    "name": "Launch via nodemon",
    "type": "node",
    "request": "launch",
    "protocol": "inspector",
    "cwd": "${workspaceRoot}",
    "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon",
    "runtimeArgs": [
        "--exitcrash",
        "--config", "${workspaceRoot}/nodemon.json",
        "--exec", "${workspaceRoot}/node_modules/.bin/ts-node",
    ],
    "args": [
        "${workspaceRoot}/src/index.ts",
        "--project", "${workspaceRoot}/tsconfig.development.json"
    ],
    "restart": true,
    "console": "integratedTerminal",
    "internalConsoleOptions": "openOnSessionStart",
    "skipFiles": [
        "node_modules/**",
        "<node_internals>/**"
    ]
},

@Deilan
Copy link
Author

Deilan commented Dec 18, 2017

Yep, that worked. 1.18.1, 1.19.0 and 1.20.0. Thanks @weinand!

@weinand weinand closed this as completed Dec 18, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants