question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deno inspector closes socket before vscode can connect

See original GitHub issue

Describe the bug Debugger only works once after reloading cache, Then exits with code 1 and next debug sessions don’t work until the command deno cache -r <file> is ran.

To Reproduce

  1. Create a simple typescript file, let’s say Hi.ts with this code : console.log('Hi');
  2. Set a breakpoint
  3. Launch Debugger using F5 (Without a launch.json file), The breakpoint hits. Once you end debugging and expect the program to end, the debugger controls just stay there; and you have to press stop to end the session.
  4. At the end of the session you’ll have an output similar to this one in console :
B:\Prog\Dev\Deno\deno.EXE run --unstable --inspect --allow-all .\Hi.ts
Hi
Hi.ts:1
Debugger listening on ws://127.0.0.1:9229/ws/9e5ecde2-ab9f-41bf-aede-e8194a78d3d4
Check file:///B:/Proj/DenoIssue/Hi.ts
Debugger session started.
Process exited with code 1
  1. Try to launch the debugger again without making any changes to the code.
  2. The debugger doesn’t work, VS Code debugging controls disappear and you’ll end up with just this line as your output :
B:\Prog\Dev\Deno\deno.EXE run --unstable --inspect --allow-all .\Hi.ts
  1. Now run this command : deno cache -r Hi.ts to reload the cache.
  2. Try to launch the debugger again, The same thing as step 3 happens, and the story continues !

Expected behavior At step 3, process is expected to exit (with code 0) after debugging is finished. At step 6, debugger is expected to work without the need to reload the cache.

Screenshots Step 3 : Debugger Working Debugger Working

Step 3 : End of Debugging, Program doesn’t exit End of Debugging

Step 4 : Process exiting with non-zero code after stopping the debugger using the controls’ stop button. Process exiting with code 1

Step 6 : Trying to debug the same code again, results in unexpected behavior Trying to debug again

Versions

VSCode :

  • Version: 1.61.0 (system setup)
  • Commit: ee8c7def80afc00dd6e593ef12f37756d8f504ea
  • Date: 2021-10-07T18:13:09.652Z
  • Electron: 13.5.1
  • Chrome: 91.0.4472.164
  • Node.js: 14.16.0
  • V8: 9.1.269.39-electron.0
  • OS: Windows_NT x64 10.0.19043

Deno :

  • deno 1.14.3 (release, x86_64-pc-windows-msvc)
  • v8 9.4.146.19
  • typescript 4.4.2

Extension : 3.9.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
kitsonkcommented, Oct 13, 2021

I think it is because the inspector drops before the connection before vscode can connect to it and express a breakpoint, so vscode fumbles a bit when trying to connect to the inspector that isn’t there anymore.

I believe the reason why the --reload fixes it in some cases is because the default inspect uses --unstable. When that occurs the configuration of the emit changes, which invalidates the previous emit, and then causes the re-re-load the code, which gives vscode enough time to connect to the inspector and set a break point.

Changing to --inspect-brk “fixes” the issue as well, though it would likely dump people into strange parts of code, and the reason we default to just --inspect.

I have opened denoland/deno#12417 to try to address it.

2reactions
KotlinIslandcommented, Oct 12, 2021

Deno is literally unusable until this is fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP Server APIs | Manual - Deno
close () method which can be used to close the listener. Serving HTTP. Once a connection is accepted, you can use Deno.serveHttp() to...
Read more >
Language Server Extension Guide - Visual Studio Code
This guide will teach you how to build a Language Client / Server using our Node SDK. ... Also include all preview /...
Read more >
Deno oak websocket must have a method that returns an ...
Here is the type documentation for WebSocket in Deno. ... Do something when a connection is closed function handleClose(ev: CloseEvent, ...
Read more >
Work with WebSockets - Flutter documentation
Close the WebSocket connection; Complete example. In addition to normal HTTP requests, you can connect to servers using WebSockets . WebSockets allow for ......
Read more >
WebSocket — Godot Engine (stable) documentation in English
This example will show you how to create a WebSocket connection to a remote ... by the remote peer before closing the socket....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found