OmniSharp / OmniSharp/csharp-language-server-protocol
Debug Adapter Server for Visual Studio Initialize issue
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 638
- Forks
- 109
- Avg merge
- 1m
- Merged PRs (30d)
- 2
Description
Hi!
I'm creating a debug adapter server with Visual Studio 2022 client.
I have encountered an issue with the server initialize process - I got the following exception from VS on Debug adapter initialize:
System.InvalidOperationException: Received 'initialized' event before response to 'initialize' request!
at Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.Engine.Implementation.DebuggedProcess.HandleInitializedEvent(InitializedEvent body)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.HandleIncomingEvent(String msg)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.ProcessMessageBody()
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.ReaderThreadProc()
When I looked at the DebugAdapterServer implementation code, I saw that the server is implementing "IDebugAdapterInitializeHandler"
and using an "_initializeComplete" subject to wait for the initialize handle function completetion. After the subject completion the server sends the Initialized event.
In practice, after marking the _initializeComplete subject as completed, we send the Initialized event even duo there is no guarantee that the Initialize response has already been sent back to the VS. We send the Initialize response only when the "Handle" method returns, and not when the _initializeComplete task completed.
Am I missing something? Is that a known issue here?
Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read src/Dap.Server/DebugAdapterServer.cs around _initializeComplete, the initialize handler, and the Handle method at the referenced lines 40, 150, 162, and 176. Reproduce the Visual Studio 2022 initialization sequence and verify that the initialize response is sent before the Initialized event; done means the exception no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100