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

Breakpoints at the startup of a program that is executed via NPM aren't being triggered #1704

Closed
gfszr opened this issue May 11, 2023 · 2 comments · Fixed by #1714
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@gfszr
Copy link
Contributor

gfszr commented May 11, 2023

Describe the bug
When running a simple Typescript script via a NPM task, breakpoints do not jump at the beginning of the execution. To emphasize this even more, I wrote a very small program that exists pretty quickly, and in it no breakpoint is jumped at all.

I suspect that, because js-debug attaches to child processes via NODE_OPTIONS injecting of a debugger script, that the script executes too quick for the debugger to actually place the breakpoints.

To Reproduce
The following app.ts code:

let i = 0
function main() {
    console.log("hello world")
}
main()

With the following run configuration:

{
    "name": "Example",
    "request": "launch",
    "runtimeArgs": [
        "run-script",
        "start"
    ],
    "runtimeExecutable": "npm",
    "outFiles": [
        "${workspaceFolder}/out/**/*.js"
    ],
    "type": "node",
    "console": "integratedTerminal",
},

And from package.json:

  "scripts": {
    "start": "node ./out/app.js",
    "build": "npx tsc -p ."
  },

VS Code Version: VSCode 1.78.1, Plugin: v1.78.0

@gfszr gfszr added the bug Issue identified by VS Code Team member as probable bug label May 11, 2023
@gfszr
Copy link
Contributor Author

gfszr commented May 11, 2023

Interestingly enough, adding a forced sleep does cause breakpoint on main() to be triggered:

let i = 0
for (i = 0; i < 100000000; i++) {
}
function main() {
    console.log("hello world")
}
main() // <== BP here

connor4312 added a commit that referenced this issue Jun 5, 2023
The filter was missed in unit testing and didn't actually work correctly. In most cases this didn't lead to a visible failure, but this fixes it.

Fixes #1704
@connor4312 connor4312 modified the milestones: May 2023, July 2023, June 2023 Jun 5, 2023
connor4312 added a commit that referenced this issue Jun 6, 2023
…#1714)

The filter was missed in unit testing and didn't actually work correctly. In most cases this didn't lead to a visible failure, but this fixes it.

Fixes #1704
@rzhao271 rzhao271 added the verified Verification succeeded label Jun 28, 2023
@rzhao271
Copy link
Contributor

I'm able to hit the breakpoint if I add it to the built app.js file. If I add it to app.ts, nothing happens, even if I then include the sleep-like for loop in the code. Is that expected? @connor4312.

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 verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants