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 scripts don't run first time with integratedTerminal #318

Closed
dancrumb opened this issue Feb 10, 2020 · 5 comments
Closed

Node scripts don't run first time with integratedTerminal #318

dancrumb opened this issue Feb 10, 2020 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug upstream
Milestone

Comments

@dancrumb
Copy link
Contributor

Following this issue: microsoft/vscode#90251, I installed the new debugger.

It solved the problem in the original issue, but brought along its own.

I have the following configuration:

{
      "type": "node",
      "request": "launch",
      "name": "API Server",
      "args": ["${workspaceFolder}/src/server.ts"],
      "console": "integratedTerminal",
      "runtimeArgs": ["-r", "ts-node/register", "-r", "tsconfig-paths/register"],
      "runtimeVersion": "12.15.0",
      "env": {
        "RAVEN_ENVIRONMENT": "local",
        "NODE_ENV": "local",
        "AWS_REGION": "us-west-2",
        "LOG_LEVEL": "debug"
      }
    },

When I start it from the "Run and Debug" panel, it opens a terminal and I get the following output:

/Users/danrumney/.nvm/versions/node/v12.15.0/bin/node -r ts-node/register -r tsconfig-paths/register /Users/danrumney/WebstormProjects/ohana/src/server.ts 
Debugger listening on ws://127.0.0.1:60446/8ed0beb3-2330-4a06-bae0-b56ec66d7d27
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
direnv: loading .envrc                                                                                                                           
➜  ohana git:(develop) ✗ /Users/danrumney/.nvm/versions/node/v12.15.0/bin/node -r ts-node/register -r tsconfig-paths/register /Users/danrumney/WebstormProjects/ohana/src/server.ts 
Debugger listening on ws://127.0.0.1:60454/3f945706-0d0c-48de-af1e-adeb2e36c52e
For help, see: https://nodejs.org/en/docs/inspector
[1]    55758 terminated  /Users/danrumney/.nvm/versions/node/v12.15.0/bin/node -r ts-node/register -r 

I ran echo $? and got an rc of 143

If I then try to run it again, everything works as I would expect it to...

@dancrumb
Copy link
Contributor Author

For the record, I followed the instructions thus:

  1. Installing the js-debug-nightly extension,
  2. Adding "debug.node.useV3": true and "debug.chrome.useV3": true to your user settings,
  3. Then you should be able to run and debug your programs without changing your launch config. If you can't, then please file an issue.

@connor4312
Copy link
Member

This is because you use nvm, which runs an npm command to get configuration when the terminal opens. The debugger right now doesn't know that npm is not what we actually want to debug--so it treats it as the main target, and then after it disconnects (i.e. the session is over) just kills everything else.

Had an issue on vscode core for this but it looks like I forgot to transfer it over--thanks for the report!

@connor4312 connor4312 added the bug Issue identified by VS Code Team member as probable bug label Feb 10, 2020
@connor4312 connor4312 added this to the February 2020 milestone Feb 10, 2020
@dancrumb
Copy link
Contributor Author

You bet. Is there any information I can provide to help or is this pretty easy for you to recreate?

@connor4312
Copy link
Member

It's easy to recreate, thank you though :)

@connor4312 connor4312 self-assigned this Feb 10, 2020
@connor4312 connor4312 modified the milestones: February 2020, Backlog Feb 11, 2020
@connor4312 connor4312 changed the title Node scripts don't run first time with new debugger Node scripts don't run first time with integratedTerminal Feb 12, 2020
@connor4312
Copy link
Member

connor4312 commented Feb 12, 2020

Fixed with microsoft/vscode@6a04aa0, should be good to go in the next Insiders build.

Testers: with pwa-node, have nvm installed in your .rc on OSX or Linux, or put node -e true in your .rc file. Then try to launch any program with "console": "integratedTerminal" and verify the program launches/isn't killed immediately.

@connor4312 connor4312 modified the milestones: Backlog, February 2020 Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug upstream
Projects
None yet
Development

No branches or pull requests

2 participants