Skip to content

Add WS bridge over DAP TCP server#4328

Open
rentziass wants to merge 3 commits intomainfrom
rentziass/debugger-ws-bridge-fix
Open

Add WS bridge over DAP TCP server#4328
rentziass wants to merge 3 commits intomainfrom
rentziass/debugger-ws-bridge-fix

Conversation

@rentziass
Copy link
Copy Markdown
Member

@rentziass rentziass commented Apr 8, 2026

This adds a bridge converting messages to/from TCP <-> WS so that we can connect to the DAP server through wss:// directly and using GitHub credentials out of the box with Dev Tunnels.

https://github.com/github/c2c-actions/issues/9831

@rentziass rentziass marked this pull request as ready for review April 8, 2026 16:43
@rentziass rentziass requested a review from a team as a code owner April 8, 2026 16:43
Copilot AI review requested due to automatic review settings April 8, 2026 16:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a WebSocket-to-TCP bridge in the DAP subsystem so remote debugging can connect via ws:///wss:// to the runner’s DAP server (e.g., through Dev Tunnels using GitHub auth), while the internal DAP server continues to speak DAP-over-TCP.

Changes:

  • Add WebSocketDapBridge to translate WebSocket text frames ↔ DAP TCP (Content-Length framed) messages.
  • Update DapDebugger startup/shutdown to expose the tunnel port via the WebSocket bridge and move the internal DAP listener to an ephemeral local port.
  • Add L0 coverage for the bridge and for DapDebugger WebSocket connectivity (including “pre-upgraded” WebSocket streams).
Show a summary per file
File Description
src/Runner.Worker/Dap/WebSocketDapBridge.cs New bridge implementation handling upgrade detection, handshake, and bidirectional message pumping.
src/Runner.Worker/Dap/DapDebugger.cs Starts/stops the bridge and uses an internal ephemeral TCP port for the actual DAP server when the bridge is enabled.
src/Test/L0/Worker/WebSocketDapBridgeL0.cs New L0 tests validating forwarding, rejection paths, message size limits, and disposal behavior.
src/Test/L0/Worker/DapDebuggerL0.cs Extends L0 tests to validate DapDebugger can accept DAP initialize via WebSocket and pre-upgraded WebSocket streams.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 7


namespace GitHub.Runner.Worker.Dap
{
internal sealed class WebSocketDapBridge : IAsyncDisposable
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to wrap this as IRunnerService, so you don't have to pass in a tracer.

_trace.Info($"WebSocket DAP bridge listening on {_listener.LocalEndpoint} -> 127.0.0.1:{_targetPort}");
}

public async ValueTask DisposeAsync()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to explicit shutdown the WebSocketDapBridge from the caller?
ex: we can just make a method call public async Task Shutdown()

Co-authored-by: Tingluo Huang <tingluohuang@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants