Skip to content

Dap initialization and request issues. #486

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

Closed
pengsongkun741 opened this issue Dec 24, 2020 · 5 comments
Closed

Dap initialization and request issues. #486

pengsongkun741 opened this issue Dec 24, 2020 · 5 comments

Comments

@pengsongkun741
Copy link

I am trying to use Dap Client to interact with nodejs debug adapter.
But cannot successfully call the initialization request. After confirming that the server received the initialization request and returned the result, the client code was stuck in this step.

public async Task Initialize(CancellationToken token)
        {
            await DebugAdapterEventingHelper.Run(
                _initializeDelegates,
                (handler, ct) => handler(this, ClientSettings, ct),
                _initializeHandlers.Union(_collection.Select(z => z.Handler).OfType<IOnDebugAdapterClientInitialize>()),
                (handler, ct) => handler.OnInitialize(this, ClientSettings, ct),
                _concurrency,
                token
            ).ConfigureAwait(false);

            RegisterCapabilities(ClientSettings);

            _connection.Open();
            var serverParams = await this.RequestDebugAdapterInitialize(ClientSettings, token).ConfigureAwait(false);

            ServerSettings = serverParams;

            await DebugAdapterEventingHelper.Run(
                _initializedDelegates,
                (handler, ct) => handler(this, ClientSettings, ServerSettings, ct),
                _initializedHandlers.Union(_collection.Select(z => z.Handler).OfType<IOnDebugAdapterClientInitialized>()),
                (handler, ct) => handler.OnInitialized(this, ClientSettings, ServerSettings, ct),
                _concurrency,
                token
            ).ConfigureAwait(false);

            _receiver.Initialized();

            //await _initializedComplete.ToTask(token);

            await DebugAdapterEventingHelper.Run(
                _startedDelegates,
                (handler, ct) => handler(this, ct),
                _startedHandlers.Union(_collection.Select(z => z.Handler).OfType<IOnDebugAdapterClientStarted>()),
                (handler, ct) => handler.OnStarted(this, ct),
                _concurrency,
                token
            ).ConfigureAwait(false);

            _instanceHasStarted.Started = true;
        }

In the comment statement on line 24:

await _initializedComplete.ToTask(token);

the value of token is always false, so the program just waits here and cannot continue.
I have obtained the data returned by the server in the client.ServerSettings property, which should indicate that the server has successfully responded to the request.

There is another problem. When I called the 'Launch' request, the 'noDebug' parameter was passed, but the server did not receive the parameter. I don't know what happened in the middle.

var breakResponse = await client.SetBreakpoints(new SetBreakpointsArguments() {
                Source = source,
                Breakpoints = breakPoints,
                SourceModified = false
            });

var launchResponse = await client.Launch(new LaunchRequestArguments() {
                NoDebug = false,
            });

It is also the first time for me to use DAP protocol for communication. This process is more difficult for me
So sometimes I cannot find out whether the problem is on the client side or on the server side. If possible, can you try to test the communication with the Vscode-node-debug2 debug server?
Thanks in advance!

Since I cannot upload some screenshots on the company’s intranet, please let me know if you need more information
More Information:
Dap Client: Omnisharp Dap Client(v0.19.0-beta.4)
Dap Server: vscode-node-debug2(v1.42.5)

@david-driscoll
Copy link
Member

So the server should be sending the InitializedEvent back which should complete that task, so if the server never sends that task... things break down. I'll review and reply back shortly.

@david-driscoll
Copy link
Member

So it's getting stuck at the initialized event as I figured.

Problem is I don't know the "right" way to fix this. The spec says it's an required event. We could simply ignore the initialized event or timeout after a certain time but then the server is in an unknown state at least from the client perspective.

@david-driscoll
Copy link
Member

The only thing I think might help is moving up a few lines to just after RequestDebugAdapterInitialize.

@pengsongkun741
Copy link
Author

Thank you for your reply!The nodejs debugging server has been used in Vscode. Maybe we can look at its source code reference to the correct processing method。In addition, can Dap Client be used for product development now? Next year we may need to use Dap Client to support code debugging on .net projects.I don't know if the communication failure is caused by the difference of various debugging adapters
Thanks!

@david-driscoll
Copy link
Member

I think it can be, obviously we might run into bugs from time to time. I haven't gone and pushed a 1.0 just yet because I'm waiting to make sure that there aren't any other breaking changes that might need to be made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants