vscode_deno icon indicating copy to clipboard operation
vscode_deno copied to clipboard

--watch flag causes vscode debugger to crash

Open mwk24 opened this issue 8 months ago • 4 comments

Run the project with --watch and --inspect-wait flags. When a file is edited, the debug sessions stops and the deno process dies.

To Reproduce

  1. Create a basic deno project. This will do:

Deno.serve((_request: Request) => { return new Response("Hello, world!"); });

Create launch.json with run flags: "runtimeArgs": [ "run", "--inspect-wait", "--watch", ]

  1. Run from vscode debugger, load browser to localhost:8000

  2. Edit a file, save.

  3. Notice that the debugger and deno have crashed.

Expected behavior

Just restart normally. It works fine if you run the same commands from the terminal (then use chrome debugger) - so obviously the vscode debugger is involved somehow.

Screenshots

Unfortunately, there is nothing useful in the runtime logs.

Versions

vscode: 1.83.1 deno 1.37.2 (release, aarch64-apple-darwin) v8 11.8.172.13 typescript 5.2.2

mwk24 avatar Oct 16 '23 20:10 mwk24

same here

hw104 avatar Oct 24 '23 07:10 hw104

I've found this as well.

I tried resolving it by adding "restart": true to the launch.json config for the debugger but that still causes issues with the output reporting.

Cannot start inspector server: error creating server listener: Address already in use (os error 48).
Process exited with code 1

Adding a delay doesn't seem to help either.

WolfieZero avatar Nov 16 '23 20:11 WolfieZero

I am facing the same issue on deno 1.40.4 (release, x86_64-pc-windows-msvc) | vscode_deno 3.33.3 | vscode 1.86.1. In my Node projects the VS Code debugger works just fine with --watch, but with Deno the debugger dies as soon as any file is changed. Are the developers aware of this issue?

bshoshany avatar Feb 12 '24 06:02 bshoshany

I'm experiencing this too but wanted to share a temporary work-around I found

  • Create a debug process that attaches to the running program. include restart: true
    • {
          "request": "attach",
          "type": "node",
          "restart": true,
          "port": 9229
      }
      
  • Launch your Deno program via commandline/task with --watch and --inspect-wait flags
  • do the attaching (via F5 or whatever)

Also works with --unstable-hmr

This way you can get auto-reloading and break-points working together.

It's kinda annoying to have to attach the debugger separately, but you only have to do it once per start-up if you have restart: true

the-andy-franklin avatar Apr 08 '24 19:04 the-andy-franklin