Skip to content

Exception not shown in VS Code if thrown after console.log() #638

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

Closed
mohd-akram opened this issue Jul 12, 2018 · 10 comments
Closed

Exception not shown in VS Code if thrown after console.log() #638

mohd-akram opened this issue Jul 12, 2018 · 10 comments
Labels

Comments

@mohd-akram
Copy link

The following code doesn't show an exception for me when debugging in VS Code:

console.log('');
throw new Error('error');

Removing console.log('') causes the exception to appear in the Debug Console. The following also works fine:

console.log('');
throw 'error';

I'm using the VS Code launch configuration mentioned in the README.

node --version: v10.6.0
code --version: 1.25.0
"ts-node": "^7.0.0"

@blakeembrey
Copy link
Member

Can you share your configuration? I’m not very familiar with this feature.

@mohd-akram
Copy link
Author

tsconfig.json and VS Code settings are blank. Here's the launch.json for VS Code:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "runtimeArgs": [
        "-r",
        "ts-node/register"
      ],
      "args": [
        "${workspaceFolder}/test.ts"
      ]
    }
  ]
}

@mohd-akram
Copy link
Author

After debugging for a while, I've narrowed it down to this line which installs source map support. Commenting it out causes the exception to show properly. I've confirmed that this isn't a VS Code issue by trying the same thing in the Chromium debugger (node -r ts-node/register --inspect-brk test.ts).

@blakeembrey
Copy link
Member

You might want to report the issue on that module.

@mohd-akram
Copy link
Author

It is indeed a problem there. I'm curious why this library is needed in the first place though. The stack traces are correct for me without it.

@blakeembrey
Copy link
Member

They aren’t for me, hence the addition. Are you looking at stack traces in the console or in VS code - I bet the inspector protocol does source code mapping for you.

@mohd-akram
Copy link
Author

Hmm, you're right.

@blakeembrey
Copy link
Member

Feel free to link the issue back to here so the others can track the progress if they run into the same issue 👍

@mohd-akram
Copy link
Author

I commented on the PR that introduced this issue - evanw/node-source-map-support#208.

@mohd-akram
Copy link
Author

As a workaround, you can add "outputCapture": "std" to launch.json in VS Code.

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

2 participants