Repository navigation
Description
What
- Progress events:
progressStart,progressUpdateandprogressEnd. An adapter should send them only if the client setsupportsProgressReportingininitialize. - The
cancelrequest: gated by the capabilitysupportsCancelRequest. ItsrequestIddrops interest in an earlier request; itsprogressIdcancels a progress. It is best effort:- a cancelled request still answers, normally or with the error message
cancelled; - a cancelled progress still ends with
progressEnd.
- a cancelled request still answers, normally or with the error message
Why
Progress events:
- lldb-dap sends all three. It starts its progress thread only when the client sent
supportsProgressReporting(lldb/tools/lldb-dap/DAP.cpp:1267-1268;ProgressEvent.cpp:69, 76, 82). - vscode-js-debug sends
progressStart"Waiting for browser approval" andprogressEnd(src/targets/browser/browserAttacher.ts:346, 361), without checking the flag. During that wait it acceptscancelwith thatprogressId(:337-343), although it doesn't advertisesupportsCancelRequest. - No progress events: debugpy, CodeLLDB, Delve, netcoredbg, rdbg, GDB, MIEngine, java-debug.
Cancel by requestId:
- CodeLLDB: for scopes, variables and evaluate (
debug_session.rs:599,:309-316). It sends no response to thecancelrequest itself. - lldb-dap:
DAP.cpp:874-888. - netcoredbg:
vscodeprotocol.cpp:1128-1152. - GDB:
dap/server.py:363-371,:648-649. - None of these four uses
progressId. - No: debugpy, rdbg, MIEngine, java-debug. Delve advertises
false.
What users miss:
- There is no progress bar for long adapter work with lldb-dap.
- js-debug's wait for the browser can't be cancelled from the IDE.
- Abandoned requests keep the adapter busy. One example is Debug console completion:
DAPCompletionProcessorreturns when the lookup is cancelled (DAPCompletionProcessor.java:76), but thecompletionsrequest goes on in the adapter. Another is the stackTrace, scopes and variables requests of a stop the user has already stepped away from.
Today
createInitializeRequestArgumentsdoesn't setsupportsProgressReporting, so lldb-dap sends no progress.DAPClientdoesn't override the progress methods, and LSP4J's defaults are empty. So js-debug's progress is dropped.supportsCancelRequestis not read anywhere, and LSP4IJ never sendscancel.- Trap: LSP4IJ never cancels a DAP request future today. If it did, LSP4J 1.0.0 would not send a DAP
cancel:JsonRpcRequestFuture.cancelcallsRemoteEndpoint.sendCancelNotification, whichDebugRemoteEndpointdoesn't override;- so it sends LSP's
$/cancelRequest, whichDebugMessageTypeAdapterwrites as{"type":"event","event":"$/cancelRequest",...}. That is not DAP.
How it could be done
Progress:
- Set
supportsProgressReporting = true. - Add a
DAPProgressManagerperDAPClient. Progress IDs are unique only within a debug session, and child sessions have their own. - Model it on
LSPProgressManager.createTask: oneTask.Backgroundable(Project, String, boolean)perprogressId, fed by a queue, started withProgressManager.run(Task). Both exist in 2024.2 and 2026.3.- The title comes from
progressStart.title, perhaps prefixed with the configuration name. setText2shows the message.setFraction(percentage / 100), orsetIndeterminate(true)when there is no percentage.
- The title comes from
- Optionally wait about 500 ms before showing the task, through
AppExecutorUtil.getAppScheduledExecutorService()(both versions), and skip it ifprogressEndcame first. VS Code delays 500 ms (debugProgress.ts). - End the task on
progressEnd, and when the client terminates or is disposed. - Cancelling: the task is cancellable when
cancellableis true. When the user cancels:- send
cancelwith thatprogressId, plusrequestIdifprogressStartnamed one; - keep ignoring updates until
progressEnd("A client should not assume that progress just got cancelled").
- send
- VS Code sends this progress cancel without checking
supportsCancelRequest(debugSession.ts:900-905,rawDebugSession.ts:582-584), and js-debug relies on that. The spec says to callcancelonly with the capability. This is an open question. - Threading: event handlers only enqueue.
ProgressManager.runis called from the LSP4J thread, asLSPProgressManagerdoes.
Cancelling requests:
-
In
DAPClient.createLauncher(DAPClient.java:480), build the launcher with aDebugLauncher.Buildersubclass. It overridescreateRemoteEndpoint(MessageJsonHandler), which is protected; the original is 12 lines. -
That method returns a
DebugRemoteEndpointsubclass that overridessendCancelNotification(Either<String, Number> id). If the live capabilities havesupportsCancelRequest, it callsrequest("cancel", args)withrequestId = id.getRight().intValue(). That id is the DAPseq:DebugRemoteEndpointsets the id from its sequence counter. Otherwise it sends nothing. -
Then cancelling the root future that the proxy returns sends one DAP
cancel.JsonRpcRequestFuturesends it once, skips it if the request is done, and doesn't send for dependent stages. -
Where to use it:
DAPCompletionProcessor, when the lookup is cancelled;- after DAP: support the Continued event #2106, on resume, step or
continued: cancel the client's pending stackTrace, scopes and variables requests.
VS Code cancels per thread on
continued, and cancels everything on terminate, disconnect, restart and invalidated (debugSession.ts:1155-1160,:1330-1335,:1573-1575). -
Treat an error answer with message
cancelledas a cancellation, not as an error to show. Never wait for the answer tocancel: CodeLLDB doesn't send one. -
Compatibility: adapters without these capabilities behave as today. Of the ten adapters checked, only lldb-dap starts sending progress once the flag is set.
-
Docs: mark Cancel and the three progress events as supported in DAPSupport.md.
Test
- Progress: the in-process server calls
client.progressStart,progressUpdateandprogressEndthrough itsIDebugProtocolClientproxy. Same pattern asDAPClientCapabilitiesEventTestandDAPSessionTreeTest. Assert onDAPProgressManager's own state (active IDs, last text and fraction), not on the status bar. Also test user cancel, which should sendcancelwithprogressId. - Cancel: the server implements
cancel(CancelArguments)and holds back the answer to another request. The test cancels that request's future and asserts thatcancelarrives with the same seq.- With
supportsCancelRequestfalse, capture the raw messages through the wrapper of the 5-argumentDSPLauncher.createServerLauncher. Assert that nothing is sent, in particular no$/cancelRequestevent.
- With
- Unit test: percentage to fraction, and the handling of the error message
cancelled.
Effort and risk
Medium. The launcher change sits on every message, so keep it minimal. Open questions:
- Should the progress cancel be gated on
supportsCancelRequest? - Show progress for every session, or only the focused one, as VS Code does?
- Which requests should be cancelled on resume?
- Should the event-instead-of-request behaviour of
DebugRemoteEndpointbe reported to Eclipse LSP4J?
Related: #1866 (console evaluate), LSP progress in LSPProgressManager.
Activity
fix: cancel a DAP request with the DAP cancel request, not a $/cancel…
lagergren commentedon Nov 23, 2026
Progress: #2122, merged on 2026-11-23 for 0.30.2, takes care of the trap under "Today":
DAPClientLauncher) now sends a cancelled DAP request as the DAPcancelrequest with itsrequestId, and only to an adapter that advertisessupportsCancelRequest. To any other adapter it sends nothing.cancel.// TODO LSP4J:and tracked in Track the upstream fixes that LSP4IJ waits for or works around #2121.Still open here, since nothing in LSP4IJ cancels a DAP request yet and nothing reads progress:
supportsProgressReporting, and showingprogressStart,progressUpdateandprogressEnd.cancel.progressId.