Skip to content

Ensure Debugpy closes connection after a disconnect response - #1859

Merged
Rich Chiodo (rchiodo) merged 2 commits into
microsoft:mainfrom
AleksMat:main
Mar 7, 2025
Merged

Rich Chiodo (rchiodo) merged 2 commits into
microsoft:mainfrom
AleksMat:main

Conversation

@AleksMat

Copy link
Copy Markdown
Contributor

Until now, the process of closing the connection between Debugpy and a client (e.g. VSCode) would be the following:

  1. a client sends a disconnect request,
  2. Debugpy sends back a disconnect response acknowledging the disconnect,
  3. the client sends an empty line,
  4. Debugpy waits for an empty line and only then closes connection (link to code).

The problem is that, unlike VSCode, not all clients send this empty line. Because of that, when a user shuts down the debugger, the Debugpy's process won't die. It keeps waiting for that empty line to close the connection and at the same time occupying the communication port with the client. I believe this is the reason for the bug reported in #1783.

AFAIK, sending an empty line is not a part of the DAP protocol. Therefore, Debugpy shouldn't rely on it and should instead proactively close connection once it sends a disconnect response to the client.

This PR aims to fix this.

@AleksMat
Matej Aleksandrov (AleksMat) requested a review from a team as a code owner March 6, 2025 16:01
@AleksMat

Copy link
Copy Markdown
Contributor Author

Note: the current implementation of the fix might be a bit naive but I'm happy to iterate on the solution with some guidance.

Comment thread src/debugpy/common/messaging.py Resolved
@rchiodo

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@rchiodo

Copy link
Copy Markdown
Contributor

Thanks for the submission, Win 3.13 failures aren't related so just going to merge.

@rchiodo
Rich Chiodo (rchiodo) merged commit f054965 into microsoft:main Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants