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

debug: export runInTerminal implementation #136523

Closed
hyangah opened this issue Nov 5, 2021 · 2 comments
Closed

debug: export runInTerminal implementation #136523

hyangah opened this issue Nov 5, 2021 · 2 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@hyangah
Copy link

hyangah commented Nov 5, 2021

Our extension (go) implements most of DAP spec inside the go debugger (delve), but runInTerminal support is not one of them. I hope to utilize runInTerminal to support go but for the initial version, I want to implement it outside of the go debugger. (Long discussion: golang/vscode-go#1626)

What I want to achieve is:

  • VS Code starts a session by starting our thin adapter.
  • Our inlined debug adapter starts delve from the terminal (utilizing runInTerminal)
  • Our inlined debug adapter proxies all the requests between VS Code and delve.

According to the DAP spec, the RunInTerminal request shouldn't be used before the initialize response is sent back to the editor.

Until the debug adapter has responded to with an ‘initialize’ response, the client must not send any additional requests or events to the debug adapter.
In addition the debug adapter is not allowed to send any requests or events to the client until it has responded with an ‘initialize’ response.

However, the true debug capabilities are determined by the debugger (delve), so that complicates the logic of our inlined, proxying debug adapter.

  • responds with a bogus initialize response.
  • sends runInTerminal request and receives runInTerminal response.
  • sends initialize request to delve (now running in the terminal)
  • receives initialize response from delve, and computes the capabilities differences.
  • sends capabilities event to VS Code.

Not impossible, but I found it complicates the code, and testing is hard.
By accident, I found VS Code handles runInTerminal even before initialize response is received.

Can we rely on this unexpected behavior?

Alternatively, what do you think about exporting runInTerminal handling as a vscode debug api, and allow it to be called from createDebugAdapterDescriptor of vscode.DebugAdapterDescriptorFactory?

I considered to mimic VS Code's runInTerminal implementation by using vscode terminal APIs.
But that does not provide all the benefits (e.g. external terminal, terminal+session management, consistent UX across different languages, and finally vscode team's blessing). So, I personally prefer to utilize runInTerminal feature.

@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues under-discussion Issue is under discussion for relevance, priority, approach labels Nov 5, 2021
@hyangah
Copy link
Author

hyangah commented Nov 23, 2021

Is it ok to depend on the current behavior of VS Code for the time being? (i.e., allowing runInTerminal request sent before initialize response)

@weinand
Copy link
Contributor

weinand commented Oct 19, 2022

Yes, that's ok.

@weinand weinand closed this as completed Oct 19, 2022
@weinand weinand removed the under-discussion Issue is under discussion for relevance, priority, approach label Oct 19, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests

2 participants