-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[lldb-dap] Adjusting startup flow to better handle async operations. #140299
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
Conversation
This introduces an `AsyncRequestHandler` and partially reverse the changes from ba29e60 in that the `launch` and `attach` commands now run when we receive them. We wait to send the reply until we get the `configurationDone` request.
@JDevlieghere @da-viper I think this may work to resolve #140154 and the underlying issue I saw in #140142 without needing to change our broadcaster. Leaving as a draft for now, but all the tests are passing with this change. |
@ashgti please could you rebase the branch as there is some risv commit that failed on the CI, will test it over the weekend. |
…sending the `attach`/`launch` reply.
I haven't looked at the code yet. I was re-reading the launch sequence part of the spec [1] to make sure this still complies, and I believe it does because the spec talks about responding to the request, not about handling it.
That said, does this actually solve the underlying problems? We know that VS Code sends the launch and attach request before configuration done. It's equally valid to not do that, and do things the way they're shown in the sequence diagram, where you set breakpoints, then configuration done, then launch or attach. Won't that still hit the same problem? [1] https://microsoft.github.io/debug-adapter-protocol/overview |
I think there are 2 specific problems that we have after ba29e60.
As for the sequence, the flow has 2 parallel tracks that are independently triggered. The overall flow is:
We're actually triggering the configuration flow by sending
Maybe we should look at moving the |
Thanks for the summary and especially calling out that the launch and the configuration tracks are happening in parallel, I hadn't realized that until now. That explains what the "PAR" stands for in the sequence diagram... Things make a lot more sense now :-) Alright, yeah in that case I see how we can avoid both problems by handling the launch and attach, halting the process, doing the configuration and then sending the response. |
One more thing that comes to mind: how confident are we that all existing clients send the launch/attach in parallel with the configuration requests? If we implement what you suggest, we risk a potential deadlock when a client waits for the launch/attach to complete before sending configuration requests or inversely, if the client waits for the initialized event before sending the launch/attach. Edit: writing this also made me realize that we assume all clients send a |
I also found this diagram which covers both cases I had in mind: microsoft/vscode#4902 (comment) |
I took a look at the code and I think the approach looks good. I wonder if there's an opportunity to make this slightly more generic to avoid (1) having to change the interface (i.e. keep returning an |
I think #140331 is a cleaner way to solve this without the need for an |
This introduces an
AsyncRequestHandler
and partially reverse the changes from ba29e60 in that thelaunch
andattach
commands now run when we receive them. We wait to send the reply until we get theconfigurationDone
request.