Skip to content

Commit

Permalink
Fix #314: Occasional missing response to "configurationDone"
Browse files Browse the repository at this point in the history
Actually handle missing response to "configurationDone".

Fix comment for handling missing responses to "launch" and "attach".
  • Loading branch information
int19h committed Jul 16, 2020
1 parent 440587b commit 4069c67
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/debugpy/adapter/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,16 @@ def handle(self, request):
self.server.channel.request(request.command, arguments)
except messaging.NoMoreMessages:
# Server closed connection before we could receive the response to
# "configurationDone" - this can happen when debuggee exits shortly
# "attach" or "launch" - this can happen when debuggee exits shortly
# after starting. It's not an error, but we can't do anything useful
# here at this point, either, so just bail out.
request.respond({})
self.session.finalize(
fmt('{0} disconnected before responding to "configurationDone"', self.server)
fmt(
"{0} disconnected before responding to {1!j}",
self.server,
request.command,
)
)
return
except messaging.MessageHandlingError as exc:
Expand Down Expand Up @@ -498,12 +502,31 @@ def configurationDone_request(self, request):

try:
self.has_started = True
request.respond(self.server.channel.delegate(request))
try:
result = self.server.channel.delegate(request)
except messaging.NoMoreMessages:
# Server closed connection before we could receive the response to
# "configurationDone" - this can happen when debuggee exits shortly
# after starting. It's not an error, but we can't do anything useful
# here at this point, either, so just bail out.
request.respond({})
self.start_request.respond({})
self.session.finalize(
fmt(
"{0} disconnected before responding to {1!j}",
self.server,
request.command,
)
)
return
else:
request.respond(result)
except messaging.MessageHandlingError as exc:
self.start_request.cant_handle(str(exc))
finally:
self.start_request.respond({})
self._propagate_deferred_events()
if self.start_request.response is None:
self.start_request.respond({})
self._propagate_deferred_events()

# Notify the client of any child processes of the debuggee that aren't already
# being debugged.
Expand Down

0 comments on commit 4069c67

Please sign in to comment.