Skip to content

ProtocolClient.send breaks async stacktraces #307

Description

@int19h

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions