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

Add CancellationError #10035

Merged
merged 1 commit into from
Sep 27, 2021
Merged

Conversation

mtsmfm
Copy link
Contributor

@mtsmfm mtsmfm commented Sep 1, 2021

What it does

Fixes: #9988.

Add CancellationError to be compatible with VSCode.

#9136 (comment)

How to test

Review checklist

Reminder for reviewers

@vince-fugnitto
Copy link
Member

@mtsmfm fixes #9988?

@vince-fugnitto vince-fugnitto added the vscode issues related to VSCode compatibility label Sep 1, 2021
@mtsmfm
Copy link
Contributor Author

mtsmfm commented Sep 1, 2021

@vince-fugnitto Sorry I overlooked that issue. Yes, this PR fixes that.

@tsmaeder
Copy link
Contributor

tsmaeder commented Sep 2, 2021

@mtsmfm thanks for the PR. How can I test it? Why I'm asking is this: what happens when a plugin actually throws "CancelledError"? I think we should handle that more gracefully than to just display an error. What does VS Code do in this instance?

@mtsmfm
Copy link
Contributor Author

mtsmfm commented Sep 2, 2021

@tsmaeder

What does VS Code do in this instance?

This error was introduced to avoid showing busy error on host log.
microsoft/vscode#93686

I'm not sure the equivalent place for theia so I understand this implementation is not enough though,
it's worth to be merged since this PR can solve plugin initialization error TypeError: Class extends value undefined is not a constructor or null.

#9136 (comment)

Currently Theia can't load plugins which use newer vscode-languageserver package because it extends this class even if a plugin doesn't use this class at all.

https://github.com/microsoft/vscode-languageserver-node/blob/eba6a7308b21ab94bd412fbfa63e36964b6d82ad/client/src/common/client.ts#L2710

microsoft/vscode-languageserver-node@645eb3d

@paul-marechal
Copy link
Member

paul-marechal commented Sep 17, 2021

@tsmaeder VS Code made a function to intercept some calls and log or not some of the errors:

https://github.com/microsoft/vscode/blob/1.60.1/src/vs/workbench/api/common/extHostLanguageFeatures.ts#L1595-L1624

It is then extensively used, but they only parameterize it in a few places to ignore logging CancellationError:

Since this is just related to logging, I think it is fine to do this as a follow-up.

@paul-marechal
Copy link
Member

@mtsmfm overall the changes looks ok to me, but do you know which plugin/version I could use to compare the state of master vs your PR? I tried the latest release of rust-analyzer but I got a nasty path bug error on start, which I assume comes from our implementations...

@tsmaeder
Copy link
Contributor

@mtsmfm Theia is handling errors on remote calls generally here:

.catch((err: any) => reject(this.deserializeError(capturedError, err)))

I agree we should not delay merging this PR because we're not "properly" handling CancellationError because of the following argument: for a plugin that does not use CancellationError, nothing changes. For a plugin that does use cancellation error, we now would get a different error each time it tries to throw CancellationError. So in both cases, we end up with a log full of bogus error messages. So as far as I'm concerned, it passes the "the code is no worse than before" test.

@tsmaeder
Copy link
Contributor

The code looks good to me, but I can't provoke the error from #9136 (comment) on master. @vince-fugnitto you had analyzed the problem, right?

@vince-fugnitto
Copy link
Member

The code looks good to me, but I can't provoke the error from #9136 (comment) on master. @vince-fugnitto you had analyzed the problem, right?

@tsmaeder I don't really remember, in the issue all I did was help identify where CancellationError came from, and how someone might implement it.

@mtsmfm
Copy link
Contributor Author

mtsmfm commented Sep 20, 2021

@paul-marechal @tsmaeder Currently rust-analyzer compiles its extension for node 14, not 12. So latest rust-analyzer doesn't work because theia only supports 12 until #9936

Can you try my fork? https://github.com/mtsmfm/rust-analyzer/releases/tag/nightly

It applies a patch to change target

mtsmfm/rust-analyzer#1


I tried che-theia with this PR and with my fork (https://gist.github.com/mtsmfm/a9b34a4004d20c38caf8e06f7929feb4) and I confirmed Class extends value undefined is not a constructor or null is not appeared.
Without this PR, it'll throw Class extends value undefined is not a constructor or null error.

I got another error now though, it's not related to this PR.

Activating extension 'rust-analyzer (nightly)' failed: The language client requires VS Code version ^1.53.0 but received version 1.50.0

image

For che-theia, rust-analyzer still doesn't work since its dependency requires vscode ^1.53.0.

https://github.com/rust-analyzer/rust-analyzer/blob/f1d7f98ed07b9934286b9c4809dd4d7a47537879/editors/code/package-lock.json#L3764
https://github.com/microsoft/vscode-languageserver-node/blob/release/client/7.1.0-next.5/client/src/node/main.ts#L25

I think if you can use latest theia, it should work since theia's default is 1.53.2 now.
#9959

For che-theia, I think this patch is needed
eclipse-che/che-theia#1213

@mtsmfm
Copy link
Contributor Author

mtsmfm commented Sep 20, 2021

Or perhaps this release can work without patch since it's the last release which supports node 12

https://github.com/rust-analyzer/rust-analyzer/releases/tag/2021-08-09

@tsmaeder
Copy link
Contributor

Luckily, the newest vscode-java uses CancellationError.

Copy link
Contributor

@tsmaeder tsmaeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to test with vscode-java v.0.82.0, but we should move the type declaration.

@@ -40,6 +40,13 @@ export function isPromiseCanceledError(error: any): boolean {
return error instanceof Error && error.name === canceledName && error.message === canceledName;
}

export class CancellationError extends Error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that this is in quick-open.ts. However, this is a general class and should be moved to types-impl.ts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me correct that: we're consuming cancellation-related stuff from core/common/cancellation.ts. We probably put the implementation of the class there, as well.

@mtsmfm
Copy link
Contributor Author

mtsmfm commented Sep 27, 2021

@tsmaeder I've moved class into core/common/cancellation.ts. Can you review again?

Copy link
Contributor

@tsmaeder tsmaeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm now

@tsmaeder tsmaeder merged commit ce996cc into eclipse-theia:master Sep 27, 2021
@mtsmfm mtsmfm deleted the cancellation-error branch September 27, 2021 13:11
@vince-fugnitto vince-fugnitto added this to the 1.18.0 milestone Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CancellationError
4 participants