Debugger exceptions crash the debugger and disconnect from the client

Open
#1,006 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
devtools

Research direction

Start with the protocol-server request handling in lib/debug/server_dap.rb, especially the variable-rendering code at lines 877-921, and review commit f9f3a7fee7d37749e69de5b16689636621c4fdbd. Compare the DAP and CDP server paths and determine where an injected exception can be handled centrally. Done means protocol-server exceptions produce an error response with details while the debugger remains connected.

Written by the indexing model from the issue text.

Description

Your environment

  • ruby -v: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
  • rdbg -v: rdbg 1.8.0 {:mode=>:start, :no_color=>nil}

Describe the bug
Developing the CDP/DAP servers can be quite tedious, because any mistakes can raise exceptions that aren't caught, crash the server, and disconnect your IDE. Each time it requires restarting your debugger session.

To Reproduce

Add a raise anywhere in the protocol servers, e.g. where variables are rendered.

Expected behavior
A error response to be sent to the client, which can display a message with error details.

Instead, the exception is raised, the debug adapter crashes, and the client disconnects.

Additional context

I played around with implementing this here, and got it working for the :scope and :variables requests.

It's pretty fiddly, it looks like each when branch needs to be wrapped in a separate begin/rescue block, which is quite tedious. I wonder if there's a more central place to rescue it.

It would also need to be implemented twice, because of all this logic is duplicated between the DAP and CDP servers.

Dominant language
Ruby
Stars
1.3k
Forks
146
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/debug

All issues in ruby/debug

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.