Skip to content

Terminated Event is not fired before disconnect #523

Closed

Description

@oats4goats

Your environment

  • ruby -v: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
  • rdbg -v: rdbg 1.4.0

Describe the bug
It looks like in Remote Debug mode (DAP client nvim-dap) after the last program step, the debugger disconnects but doesn't fire 'Terminated Event'. In such situation, DAP client doesn't know the debugging of the debuggee has terminated and keeps the debug session alive forever. Thus requiring manual treatment.

To Reproduce

  1. Start a debugger with rdbg --open --port 38698 target.rb in a terminal
  2. Attach to the adapter with nvim-dap
  3. Continue or step over till the very end of the program.
  4. The debugger in the terminal disconnects.

Example of console output:

#14867:[>] {"type":"request","seq":52,"arguments":{"granularity":"statement","threadId":1},"command":"next"}
#14867:[<] {"type":"response","command":"next","request_seq":52,"success":true,"message":"Success","seq":62}
12
DEBUGGER: Disconnected.

Expected behavior
Before the debugger disconnects 'Terminated Event' is issued so the client could close the debug session properly.

Additional context
Relevant discussion in mfussenegger/nvim-dap

Activity

  1. added a commit that references this issue on Feb 11, 2022
  2. ko1 commented on Mar 25, 2022

    @ko1
    Collaborator

    mfussenegger/nvim-dap#436 solves the issue?

    It's a bit tough to observe the debuggee's liveness (because the debugger runs in same process).
    But not impossible.

    If it should be supported, I'll work it.

  3. mfussenegger commented on Mar 25, 2022

    @mfussenegger

    The discussion in mfussenegger/nvim-dap#469 and the change that resulted out of the conversion (mfussenegger/nvim-dap#481) may be relevant to this as well.

    The TL;DR version is that if the debugger process runs to completion, the debug adapter must send a terminated event. If the client sends a disconnect request before the debugger process finishes, the debug adapters behavior depends on whether a launch/attach configuration was used and on the (optional) terminateDebugee flag of the request.

  4. ko1 commented on Mar 25, 2022

    @ko1
    Collaborator

    the debug adapter must send a terminated event.

    Could you give me a reference?

  5. st0012 commented on Mar 25, 2022

    @st0012
    Member

    I think he refers to the Debug session end part of https://microsoft.github.io/debug-adapter-protocol/overview? (bottom)

  6. ko1 commented on Mar 28, 2022

    @ko1
    Collaborator

    Thank you.

    In all situations where a debug adapter wants to end the debug session, a terminated event must be fired.

    I agree it should be, but not sure when the connection was lost accidentally.

  7. added a commit that references this issue on Mar 28, 2022
  8. added a commit that references this issue on Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions