diff --git a/src/debugpy/adapter/clients.py b/src/debugpy/adapter/clients.py index 1e58802a..0b4a870a 100644 --- a/src/debugpy/adapter/clients.py +++ b/src/debugpy/adapter/clients.py @@ -700,6 +700,12 @@ class Client(components.Component): except Exception: log.swallow_exception() + # Close the client channel since we disconnected from the client. + try: + self.channel.close() + except Exception: + log.swallow_exception(level="warning") + def disconnect(self): super().disconnect() diff --git a/src/debugpy/common/messaging.py b/src/debugpy/common/messaging.py index 8ba6f025..eb29c189 100644 --- a/src/debugpy/common/messaging.py +++ b/src/debugpy/common/messaging.py @@ -1223,14 +1223,6 @@ class JsonMessageChannel(object): yield seq self.stream.write_json(message) - # Close connection after Debugpy acknowledges a disconnect request. - if ( - message.get("type") == "response" - and message.get("command") == "disconnect" - and message.get("success", False) - ): - self.stream.close() - def send_request(self, command, arguments=None, on_before_send=None): """Sends a new request, and returns the OutgoingRequest object for it.