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

Client should not eat errors #517

Closed
tsmaeder opened this issue Sep 9, 2019 · 2 comments
Closed

Client should not eat errors #517

tsmaeder opened this issue Sep 9, 2019 · 2 comments

Comments

@tsmaeder
Copy link
Contributor

tsmaeder commented Sep 9, 2019

The language client handles a lot of errors and logs and eats then instead of propagating the errors to the VS Code API. For an example, see https://github.com/microsoft/vscode-languageserver-node/blob/master/client/src/client.ts#L1403

I believe this to be a wrong pattern: the errors need to be handled in the API anyway, because extensions not based on this here library may still produce errors, so we're doing the work twice. It also hides failures from the client. If we wanted to implement metrics, for example #failed completion item requests, failures from extensions based on this library would not be counted.

I think it would be better to propagate the failures through the API, for example returning a Thenable.

@dbaeumer
Copy link
Member

The underlying reason why I implemented it that way is that the VS Code UI was not very nice when an provider failed (lots of notifications poping up). I am open to revisit this however we need to ensure that the user experience it nice as well.

@dbaeumer dbaeumer added this to the On Deck milestone Sep 17, 2019
@dbaeumer
Copy link
Member

dbaeumer commented Oct 7, 2020

This got fixed in the meantime. The method that handles request errors now does:

	public handleFailedRequest<T>(type: MessageSignature, error: any, defaultValue: T): T {
		// If we get a request cancel or a content modified don't log anything.
		if (error instanceof ResponseError) {
			if (error.code === LSPErrorCodes.RequestCancelled) {
				throw this.makeCancelError();
			} else if (error.code === LSPErrorCodes.ContentModified) {
				return defaultValue;
			}
		}
		this.error(`Request ${type.method} failed.`, error);
		throw error;
	}

@dbaeumer dbaeumer closed this as completed Oct 7, 2020
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 21, 2020
@dbaeumer dbaeumer removed this from the On Deck milestone Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants