最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

node.js - VSCode node TS debugger does not break on caught exceptions - Stack Overflow

matteradmin5PV0评论

I'm debugging some TS code and ran into a strange issue - despite "Caught Exceptions" box being checked, the debugger does not pause. I've reproduced it with this simple example:

try {
  const buf = Buffer.alloc(12);
  buf.readInt32LE(16);
} catch (e) {
  console.log(e);
}

It reaches the console.log line without breaking on the initial exception, making it hard to tell where it came from (in a real scenario with more complex code). Only directly thrown exceptions cause the debugger to break.

launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "tsx",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "tsx",
      "args": ["${relativeFile}"],
      "cwd": "${workspaceRoot}",
      "internalConsoleOptions": "openOnSessionStart"
    }
  ]
}

It does not pause on uncaught exceptions either, removing the try-catch results in process crashing with error message in console.

I'm debugging some TS code and ran into a strange issue - despite "Caught Exceptions" box being checked, the debugger does not pause. I've reproduced it with this simple example:

try {
  const buf = Buffer.alloc(12);
  buf.readInt32LE(16);
} catch (e) {
  console.log(e);
}

It reaches the console.log line without breaking on the initial exception, making it hard to tell where it came from (in a real scenario with more complex code). Only directly thrown exceptions cause the debugger to break.

launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "tsx",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "tsx",
      "args": ["${relativeFile}"],
      "cwd": "${workspaceRoot}",
      "internalConsoleOptions": "openOnSessionStart"
    }
  ]
}

It does not pause on uncaught exceptions either, removing the try-catch results in process crashing with error message in console.

Share Improve this question asked Nov 16, 2024 at 8:43 rivriv 7,4013 gold badges41 silver badges74 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Try set "skipFiles": [] in your launch.json. Caught exception affected by this config. I solve a similar problem using this config.

Post a comment

comment list (0)

  1. No comments so far