Skip to content

DAP: show progress events and support the cancel request #2107

Done

Description

@lagergren

What

  • Progress events: progressStart, progressUpdate and progressEnd. An adapter should send them only if the client set supportsProgressReporting in initialize.
  • The cancel request: gated by the capability supportsCancelRequest. Its requestId drops interest in an earlier request; its progressId cancels 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.

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" and progressEnd (src/targets/browser/browserAttacher.ts:346, 361), without checking the flag. During that wait it accepts cancel with that progressId (:337-343), although it doesn't advertise supportsCancelRequest.
  • 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 the cancel request 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: DAPCompletionProcessor returns when the lookup is cancelled (DAPCompletionProcessor.java:76), but the completions request goes on in the adapter. Another is the stackTrace, scopes and variables requests of a stop the user has already stepped away from.

Today

  • createInitializeRequestArguments doesn't set supportsProgressReporting, so lldb-dap sends no progress.
  • DAPClient doesn't override the progress methods, and LSP4J's defaults are empty. So js-debug's progress is dropped.
  • supportsCancelRequest is not read anywhere, and LSP4IJ never sends cancel.
  • Trap: LSP4IJ never cancels a DAP request future today. If it did, LSP4J 1.0.0 would not send a DAP cancel:
    • JsonRpcRequestFuture.cancel calls RemoteEndpoint.sendCancelNotification, which DebugRemoteEndpoint doesn't override;
    • so it sends LSP's $/cancelRequest, which DebugMessageTypeAdapter writes as {"type":"event","event":"$/cancelRequest",...}. That is not DAP.

How it could be done

Progress:

  • Set supportsProgressReporting = true.
  • Add a DAPProgressManager per DAPClient. Progress IDs are unique only within a debug session, and child sessions have their own.
  • Model it on LSPProgressManager.createTask: one Task.Backgroundable(Project, String, boolean) per progressId, fed by a queue, started with ProgressManager.run(Task). Both exist in 2024.2 and 2026.3.
    • The title comes from progressStart.title, perhaps prefixed with the configuration name.
    • setText2 shows the message.
    • setFraction(percentage / 100), or setIndeterminate(true) when there is no percentage.
  • Optionally wait about 500 ms before showing the task, through AppExecutorUtil.getAppScheduledExecutorService() (both versions), and skip it if progressEnd came 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 cancellable is true. When the user cancels:
    • send cancel with that progressId, plus requestId if progressStart named one;
    • keep ignoring updates until progressEnd ("A client should not assume that progress just got cancelled").
  • 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 call cancel only with the capability. This is an open question.
  • Threading: event handlers only enqueue. ProgressManager.run is called from the LSP4J thread, as LSPProgressManager does.

Cancelling requests:

  • In DAPClient.createLauncher (DAPClient.java:480), build the launcher with a DebugLauncher.Builder subclass. It overrides createRemoteEndpoint(MessageJsonHandler), which is protected; the original is 12 lines.

  • That method returns a DebugRemoteEndpoint subclass that overrides sendCancelNotification(Either<String, Number> id). If the live capabilities have supportsCancelRequest, it calls request("cancel", args) with requestId = id.getRight().intValue(). That id is the DAP seq: DebugRemoteEndpoint sets the id from its sequence counter. Otherwise it sends nothing.

  • Then cancelling the root future that the proxy returns sends one DAP cancel. JsonRpcRequestFuture sends 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 cancelled as a cancellation, not as an error to show. Never wait for the answer to cancel: 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, progressUpdate and progressEnd through its IDebugProtocolClient proxy. Same pattern as DAPClientCapabilitiesEventTest and DAPSessionTreeTest. Assert on DAPProgressManager's own state (active IDs, last text and fraction), not on the status bar. Also test user cancel, which should send cancel with progressId.
  • Cancel: the server implements cancel(CancelArguments) and holds back the answer to another request. The test cancels that request's future and asserts that cancel arrives with the same seq.
    • With supportsCancelRequest false, capture the raw messages through the wrapper of the 5-argument DSPLauncher.createServerLauncher. Assert that nothing is sent, in particular no $/cancelRequest event.
  • 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 DebugRemoteEndpoint be reported to Eclipse LSP4J?

Related: #1866 (console evaluate), LSP progress in LSPProgressManager.

Activity

  1. added
    enhancement
    dap
    on Nov 22, 2026
  2. lagergren commented on Nov 23, 2026

    @lagergren
    CollaboratorAuthor

    Progress: #2122, merged on 2026-11-23 for 0.30.2, takes care of the trap under "Today":

    Still open here, since nothing in LSP4IJ cancels a DAP request yet and nothing reads progress:

    • Progress events: supportsProgressReporting, and showing progressStart, progressUpdate and progressEnd.
    • Cancelling: a cancelled lookup or task, such as the Debug console completion, cancelling the future of its request, which now sends cancel.
    • Cancelling a progress by its progressId.
  3. modified the milestones: Backlog, 0.30.3 on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIdapenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions