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

Node.js debug: New process is being created after each debugger restart #28108

Closed
Deilan opened this issue Jun 6, 2017 · 5 comments
Closed
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *not-reproducible Issue cannot be reproduced by VS Code Team member as described

Comments

@Deilan
Copy link

Deilan commented Jun 6, 2017

  • VS Code Version: 1.12.2
  • OS Version: Windows 8.1 x64
  • Node.js Version: 7.10.0

I have a nodemon with ts-node, which watch for changes in TypeScript code and recompile every time it happens. In .vscode/launch.json I set "request": "launch" and console: "externalTerminal" and start debug. Everytime I change code a new process starts while the previous is still currently active. Figure:

image

Repro:

  1. git clone https://github.com/Deilan/node-typescript-vscode.git (Web)
  2. npm i
  3. Replace launch.json's contents with the contents below.
  4. Launch Launch via nodemon debug configuration.
  5. Wait till the debugger connects to the process.
  6. Change ./src/index.ts in any way

Expect:
The process continue execution and debugger reconnects to it.
OR
The process finishes and debugger create a new process and connects to it.
(I'm not yet sure what is more correct by design)

Actual:
The process continues exection, debugger launches a new process and connects to it.

.vscode/launch.json:

{
        {
            "name": "Launch via nodemon",
            "type": "node",
            "request": "launch",
            "protocol": "inspector",
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon",
            "runtimeArgs": [
                "--exitcrash",
                "--exec",
                "${workspaceRoot}/node_modules/.bin/ts-node",
                "${workspaceRoot}/src/index.ts"
            ],
            "windows": {
                "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon.cmd"
            },
            "restart": true,
            "console": "externalTerminal"
        },
    ]
}
@roblourens roblourens assigned isidorn and unassigned roblourens Nov 21, 2017
@roblourens roblourens added debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality labels Nov 21, 2017
@isidorn
Copy link
Contributor

isidorn commented Nov 22, 2017

@Deilan can you stil reproduce this with latest vscode inisders from here
https://code.visualstudio.com/insiders/
Or with the latest vscode stable?

@isidorn isidorn added the info-needed Issue requires more information from poster label Nov 22, 2017
@roblourens
Copy link
Member

I was able to @isidorn. I read it as a feature request to reuse the previously launched external terminal. I have no idea if we're actually able to do that or not.

@auchenberg
Copy link
Contributor

Shouldn't the launched Node process be killed once debugging has been stopped?

@isidorn
Copy link
Contributor

isidorn commented Nov 23, 2017

Fowarding to @weinand since he did the external temrinal support in vscode and might know if there is already a issue capturing the request to always reuse the previously launched external terminal.

@isidorn isidorn assigned weinand and unassigned isidorn Nov 23, 2017
@isidorn isidorn removed the info-needed Issue requires more information from poster label Nov 23, 2017
@weinand
Copy link
Contributor

weinand commented Feb 23, 2018

For recent versions of VS Code the launch config must be slightly modified (and can be simplified):

{
    "name": "Launch via nodemon",
    "type": "node",
    "request": "launch",
    "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon",
    "runtimeArgs": [
        "--exitcrash",
        "--exec",
        "${workspaceRoot}/node_modules/.bin/ts-node",
    ],
    "args": [
        "${workspaceRoot}/src/index.ts"
    ],
    "restart": true,
    "console": "externalTerminal"
}

In addition change index.ts to this:

import { Greeter } from "./greeter";

const greeter = new Greeter<string>("Hello, world");

setInterval(() => {
    // tslint:disable-next-line:no-console
    console.log(greeter.greet());
}, 1000);

With the "setInterval" instead of "setTimeout" the program keeps running (which makes more sense in a nodemon setup).

With this, the setup works fine for me on macOS and Windows 10.

@weinand weinand closed this as completed Feb 23, 2018
@weinand weinand added *not-reproducible Issue cannot be reproduced by VS Code Team member as described and removed feature-request Request for new features or functionality labels Feb 23, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 10, 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 *not-reproducible Issue cannot be reproduced by VS Code Team member as described
Projects
None yet
Development

No branches or pull requests

5 participants