Skip to content

Debug Adapter Server for Visual Studio Initialize issue #982

Open
@alonsh9

Description

@alonsh9

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions