最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论