Skip to content

Commit 16a1952

Browse files
committed
Log error on missing callback and don't trigger listeners
Closes #699
1 parent cf94cfb commit 16a1952

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lua/dap/session.lua

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,8 @@ function Session:handle_body(body)
849849
self.message_requests[decoded.request_seq] = nil
850850
self.message_callbacks[decoded.request_seq] = nil
851851
if not callback then
852-
log.warn('No callback for ', decoded)
853-
callback = function() end
852+
log.error('No callback found. Did the debug adapter send duplicate responses?', decoded)
853+
return
854854
end
855855
if decoded.success then
856856
vim.schedule(function()
@@ -1339,12 +1339,15 @@ function Session:request(command, arguments, callback)
13391339
callback = function(err, result)
13401340
coroutine.resume(co, err, result)
13411341
end
1342+
else
1343+
-- Assume missing callback is intentional.
1344+
-- Prevent error logging in Session:handle_body
1345+
callback = function(_, _)
1346+
end
13421347
end
13431348
end
1344-
if callback then
1345-
self.message_callbacks[current_seq] = callback
1346-
self.message_requests[current_seq] = arguments
1347-
end
1349+
self.message_callbacks[current_seq] = callback
1350+
self.message_requests[current_seq] = arguments
13481351
send_payload(self.client, payload)
13491352
if co then
13501353
return coroutine.yield()

0 commit comments

Comments
 (0)