Skip to content

Improve shutdown sequence of DebugAdapter #110

Closed

Description

@daviwil

There is a timing issue with the shutdown sequence of the DebugAdapter which occasionally causes test hangs because the terminated event is not received. My guess is that this event never gets fully sent because of the timing of the shutdown sequence relative to some event handlers that get fired at that time. Compare the following two log files, the invocation state changes are interesting.

GoodRun.log.txt
BadRun.log.txt

There are some additional notes in the BadRun.log.txt file at the end.

It's likely that the shutdown sequence will need to be rethought so that the order of events is predictable and all messages get sent before the process terminates.

Activity

  1. added this to the milestone on Jan 10, 2016
  2. rkeithhill commented on Feb 28, 2016

    @rkeithhill
    Contributor

    BTW in StdioClientChannel.cs I wonder if we should change wrap this call:

    this.serviceProcess.Kill();

    in a try/catch. I've observed this line throwing at times when running the unit tests (usually when I've screwed up something) because the service has already exited and then we try to kill it.

  3. daviwil commented on Feb 28, 2016

    @daviwil
    ContributorAuthor

    Definitely, good point. I'll take that into account when I work on this. I've got some stuff I've already started to improve the async model so that CancellationTokens and failures flow through more easily (also with a fix for the CPU spin in MesaageReader). Will try to get that in for 0.5.0.

  4. rkeithhill commented on Mar 1, 2016

    @rkeithhill
    Contributor

    I also notice this issue when I'm manually stepping through a unit test. By the time I get to the line that sends the DisconnectRequest, the process has already terminated. That results in an unhandled exception and causes the unit test to fail. These tests rarely (if ever) fail this way when when not run under the debugger but we gotta be able to debug unit tests, right. :-)

  5. daviwil commented on Mar 1, 2016

    @daviwil
    ContributorAuthor

    Yeah, it needs to work correctly for sure. I keep seeing an annoying ThreadAbortException when running the tests in the debugger, is that what you're seeing too?

  6. rkeithhill commented on Mar 1, 2016

    @rkeithhill
    Contributor

    I don't think that was what I was seeing but I was "experimenting" and likely causing the host to exit prematurely. :-)

  7. added a commit that references this issue on Feb 26, 2019
  8. removed this from the milestone on Aug 17, 2021
  9. andyleejordan commented on Jun 15, 2026

    @andyleejordan
    Member

    Believed resolved — DAP shutdown is handled by DisconnectHandler. Closing as completed; reopen if shutdown still hangs.


    Drafted by GitHub Copilot (Claude Opus 4.8) at Andy Jordan (@andyleejordan)'s request.

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

    Issue-Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions