microsoft / vscode-debugadapter-node

Debug adapter protocol and implementation for VS Code.
Other
270 stars 77 forks source link

ProtocolClient.send breaks async stacktraces #307

Open int19h opened 2 months ago

int19h commented 2 months ago

The following implementation: https://github.com/microsoft/vscode-debugadapter-node/blob/1621133e71527d9d46438edb766eaf8e731b68f5/testSupport/src/protocolClient.ts#L69-L80 is not async itself and returns the promise immediately without awaiting it. Consequently, if the promise gets rejected with an error, the stack trace in the error does not include either send or its caller. This unnecessarily complicates debugging of e.g. async unit tests that await send() and receive an unexpected error response.

Instead, the callback for doSend should capture the raw response in a wrapper promise, and then send should await that promise and translate it to a throw.

connor4312 commented 2 months ago

Makes sense, PR welcome if you're up for it