Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance debugger attachment requests #2431

Merged
merged 2 commits into from
Aug 13, 2024
Merged

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Aug 12, 2024

Motivation

Port and host support closes #1787
Socket path support is required for https://github.com/Shopify/team-ruby-dx/issues/926

Implementation

Automated Tests

Manual Tests

  1. Run the extension with a Rails project as the extension development host
  2. To test debugSocketPath:
    1. Run the server with RUBY_DEBUG_SOCK_PATH=/tmp/debug-socket-test bundle exec rdbg -O -n -c -- bin/rails s
    2. Check attaching with the vanilla attaching config failed:
          {
              "type": "ruby_lsp",
              "name": "Attach to rdbg server",
              "request": "attach",
          }
    3. Check attaching with debugSocketPath succeeded:
          {
              "type": "ruby_lsp",
              "name": "Attach to rdbg server",
              "request": "attach",
              "debugSocketPath": "/tmp/debug-socket-test"
          }
  3. To test debugPort and debugHost:
    1. Run the server with bundle exec rdbg -p 1234 -O -n -c -- bin/rails s
    2. Check attaching with the vanilla attaching config failed:
          {
              "type": "ruby_lsp",
              "name": "Attach to rdbg server",
              "request": "attach",
          }
    3. Check attaching with debugPort succeeded:
          {
              "type": "ruby_lsp",
              "name": "Attach to rdbg server",
              "request": "attach",
              "debugPort": 1234
          }
    4. Check attaching with incorrect debugHost failed:
          {
              "type": "ruby_lsp",
              "name": "Attach to rdbg server",
              "request": "attach",
              "debugPort": 1234,
              "debugHost": "foobar" # should cause `getaddrinfo ENOTFOUND foobar` error
          }

@st0012 st0012 added the enhancement New feature or request label Aug 12, 2024
@st0012 st0012 self-assigned this Aug 12, 2024
@st0012 st0012 requested a review from a team as a code owner August 12, 2024 21:37
@st0012 st0012 requested review from andyw8 and vinistock August 12, 2024 21:37
@st0012 st0012 added the vscode This pull request should be included in the VS Code extension's release notes label Aug 12, 2024
Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

I just have an ergonomics comment, but it looks good to me

Comment on lines +478 to +485
"debugPort": {
"type": "number",
"description": "The port to use to connect to the debugger"
},
"debugHost": {
"type": "string",
"description": "The host to use to connect to the debugger"
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we combine these two into a single URI? I think it makes it even simpler for the user and we can easily split the host and port by using VS Code's URI API:

const uri = vscode.Uri.parse(session.configuration.debugUri)
uri.host
uri.port

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer having them separated because:

  1. When connecting with a remote console, the usage is rdbg -A host port, not rdbg -A host:port. When specifying with env, it has RUBY_DEBUG_HOST and RUBY_DEBUG_PORT but no RUBY_DEBUG_URI either. So I think having them separated is more consistent with the terminal experience.
  2. port is going to be specified a lot more often than host, which means in most cases debugUri would simply be port, like debugUri: 4000. And IMO debugPort: 4000 is a lot less confusing than it.

@st0012 st0012 merged commit 3f2046a into main Aug 13, 2024
35 of 36 checks passed
@st0012 st0012 deleted the enhance-debugger-attachment-requests branch August 13, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attach to debug session by port number instead of socket
2 participants