Skip to content
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

ProtocolClient.send breaks async stacktraces #307

Open
int19h opened this issue Jul 1, 2024 · 1 comment
Open

ProtocolClient.send breaks async stacktraces #307

int19h opened this issue Jul 1, 2024 · 1 comment
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@int19h
Copy link

int19h commented Jul 1, 2024

The following implementation:

public send(command: string, args?: any): Promise<DebugProtocol.Response> {
return new Promise((completeDispatch, errorDispatch) => {
this.doSend(command, args, (result: DebugProtocol.Response) => {
if (result.success) {
completeDispatch(result);
} else {
errorDispatch(new Error(result.message));
}
});
});
}

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
Copy link
Member

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

@connor4312 connor4312 added the bug Issue identified by VS Code Team member as probable bug label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants
@int19h @connor4312 and others