3

I am a reccent deno user. Been using node for a long time, switched to deno and am very happy with it. It's really good

However, I have an issue.
Whenever I try to debug a deno file, the vscode debugger starts running for like half a second and then stops, and nothing happens. It doesnt freeze or anything, it just starts for a moment and stops.

I am using this as launch configuration

{ "version": "0.2.0", "configurations": [ { "name": "Deno1", "type": "node", "request": "launch", "cwd": "${workspaceFolder}", "runtimeExecutable": "deno", "outputCapture": "std", "runtimeArgs": ["run", "--inspect-brk", "-A", "${fileName}"], "port": 9229, } ] } 

I took it from this post

I should add that I was able to debug this file already, but one day it just started showing this issue i just described without (to my knowledge) any change on my part.

I am trying to debug this file

How can I fix this issue?

3
  • Also, make sure you're using "test" as your first runtime argument, not "run" or you won't be able to set breakpoints or use the debugger Commented Nov 3, 2023 at 11:28
  • I just encountered this same problem out of the blue. Everything has been working fine for months, but now launching in VS Code does nothing. My first runtime argument is "run," and I've been able to set breakpoints and use the debugger. My config file contains the "program" entry and does say "attachSimplePort." Commented Jun 16, 2024 at 21:50
  • For anyone who encounters this suddenly: It may be a Deno bug. That's what I encountered, after Deno 1.44.2 broke debugging altogether. Commented Jun 18, 2024 at 1:49

1 Answer 1

2

To make it work you need to add a "program" field to launch.json and move the path of the file there, which is briefly mentioned in this answer from the post you linked to. But also you need to change "port" to "attachSimplePort":

{ "version": "0.2.0", "configurations": [ { "request": "launch", "name": "Launch Program", "type": "node", "program": "${workspaceFolder}/main.ts", "cwd": "${workspaceFolder}", "runtimeExecutable": "deno", "runtimeArgs": [ "run", "--inspect-wait", "--allow-all" ], "attachSimplePort": 9229, "outputCapture": "std", } ] } 

You can change the file in program if your program has an entrypoint different from main.ts. With this config you should be able to debug using F5 in VS Code and stop at any break points.

Sign up to request clarification or add additional context in comments.

5 Comments

Interesting info, thanks. I just encountered the same problem as the OP, and I have all of this except the "test" argument. I've never altered this; mine says "run," and I've been able to set breakpoints and debug.
I've updated my answer a bit. Using run should work, no need to use "test". I believe at one point there was support for debugging Deno test files run with the deno test command, but I'm not sure if that's still the case.
Thanks. As it turns out, there's a bug in Deno 1.44.2 that breaks debugging entirely.
Is there an issue for that bug?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.