-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
vsx: add 'engines' handling #8063
vsx: add 'engines' handling #8063
Conversation
48ec958
to
fac4a68
Compare
Fixes: eclipse-theia#7464 The following commit updates the `vsx-registry` to perform checks on vscode extensions to ensure that they meet the `engines.vscode` requirement that the default API version declares. The pull request: - fetches the latest compatible extension from the marketplace (instead of the latest) - adds handling to determine if a `engines.vscode` is valid - includes the version to the `vsx-editor`. Co-authored-by: Kaiyue Pan <kaiyue.pan@ericsson.com> Co-authored-by: Anas Shahid <muhammad.shahid@ericsson.com> Co-authored-by: vince-fugnitto <vincent.fugnitto@ericsson.com> Signed-off-by: Kaiyue Pan <kaiyue.pan@ericsson.com> Signed-off-by: Anas Shahid <muhammad.shahid@ericsson.com>
fac4a68
to
b1ed4d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have performance concerns with the approach. For each search instead of doing one request, we do several additional requests for each extension. The same during the install and look up of an individual extension.
@@ -49,6 +50,9 @@ export class VSXExtensionsModel { | |||
@inject(VSXExtensionsSearchModel) | |||
readonly search: VSXExtensionsSearchModel; | |||
|
|||
@inject(VSXEnvironment) | |||
protected readonly environment: VSXEnvironment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused?
* | ||
* @returns `true` if the engine satisfies the API version. | ||
*/ | ||
export function isEngineValid(engines: string[]): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/eclipse-theia/theia/wiki/Coding-Guidelines#di-function-export
please don't create many utils file, it tells i don't know to which class this responsibility should belong, so here is a sink file for all such functions. Please add it as a method to some appropriate class. In this case it can just stay in VSXReigstryApi
.
@@ -139,12 +143,18 @@ export class VSXExtensionsModel { | |||
const searchResult = new Set<string>(); | |||
for (const data of result.extensions) { | |||
const id = data.namespace.toLowerCase() + '.' + data.name.toLowerCase(); | |||
const extension = await this.api.getLatestCompatibleExtension(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks expensive to query for each found extension
*/ | ||
async getLatestCompatibleExtension(id: string): Promise<VSXExtensionRaw | undefined> { | ||
const extension = await this.getExtension(id); | ||
for (const extensionVersion in extension.allVersions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder should not it be rather solved in the registry? For each extension we will do potentially many server requests. I imagine there should be one request to fetch an extension by id for such vscode engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder should not it be rather solved in the registry? For each extension we will do potentially many server requests. I imagine there should be one request to fetch an extension by id for such vscode engine.
It would be good to enhance the registry API to also accept the engines.vscode
as an optional query parameter and only return the latest compatible result.
Would you be fine to improve the API to accept such a query parameter and add the logic to determine the latest compatible extension directly in the registry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @spoenemann
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if e.g. VScodium, that now uses Open VSX though an adapter, is able to pick a version of an extension to install, that is appropriate to it's own API version? Presumably this would be done client-side too? Potentially in a better optimised way?
As per discussions on this PR, the ideal solution would be server-side and avoid playing ping-pong like the client-side version in this PR does. Depending on the ETA of required server-side enhancements, it could be worthwhile to still merge a simpler version of this PR, and update in a follow-up PR to use server-side checks when available. The performance concerns are valid, with the current client-side implementation. To lessen performance impacts, I propose we, for Extensions Search:
For Extension Install I think we'll need multiple requests, until we have server support. But for the majority of extensions, the latest version will be compatible, so we might first check if latest is compatible, and if not, trigger a more costly search for a compatible version. @vince-fugnitto WDYT? |
I would be fine to implement the simple minimal solution first, and when the registry is ready to support the As an improvement I think we can notify end-users (notification) whenever we need to install an older version (compatible) of an extension so at least we are transparent. It will avoid confusion of why they might see an older extension version than the one listed in the view and readme. |
Thank you @akosyakov @vince-fugnitto @marcdumais for your reviews and suggestions. I do agree, it is expensive to have multiple API calls during the search. If the server could have a check for the engine, then it will be great as it can return the compatible version(s) if any. What we can keep from this PR is, when we open the extension in the editor(view), only then we update the selected extension to take the What do you guys think of this approach? |
in https://github.com/eclipse-theia/theia/pull/8063/files#r443640909 @marcdumais-work did a very good point, the difference it that for VS Code we return engine associated with each version, so there is not need for additional requests.
it still can make install slow to loop over all versions for each extension. |
@akosyakov do we have access to this same API, do you have example? If so, we can easily determine the valid version and perform the changes client side (like vscode). |
It should be about a single extension at this point, that the user has selected, presumably to get more info before deciding to install or not. He may do the same with another extension in 10s, but it's only done for one extension at a time. @Anasshahidd21 - I think we should to confirm what a worse-case situation would be like. e.g. will the user notice a delay if we need to search deep for a compatible version of an extension vs if latest is compatible. Maybe have little videos to show us? |
The test extension I used was RedHat Java, the API link for it is here. Considering latest version is compatible - This PR
Considering latest version is not compatible- This PR
Considering latest version is compatible - MASTER
Analysis
|
Thanks Anas. So: It makes sense that this would grow about linearly with the number of versions checked for compatibility - the checks does not become more costly for subsequent versions. We also have a baseline time of ~50ms to display the README without any version compatibility checking. We can approximate this so: t =~ 50ms + 60ms * n, where n = number of versions of an extension that is checked for API compatibility We can extrapolate that if there needs to be 10 versions checked before finding a compatible one. it will take: In 1 second, we can search how many versions? Context
Potential Optimization
|
We could make a PR to open vsx registry to expose vscode engine for each version as well, redeploy and make use of it? |
@akosyakov I think exposing the engine as part of the version (presumably the |
There is even already code doing it for VS Code adapter: https://github.com/eclipse/openvsx/blob/cae067ede155e36e5bf48c4c93e97074bfac1256/server/src/main/java/org/eclipse/openvsx/adapter/VSCodeAdapter.java#L359 |
Closing. The goal would be first to update the Upstream Issue: |
What it does
Fixes: #7464
The following commit adds additional handling and functionality to the
vsx-registry
extension in order to obtain the latest compatible version of an extension (instead of the latest) by verifying it'sengines.vscode
property. A compatible extension is defined as one which respects the default API version of the framework, and is useful to narrow down the list of potential extensions to those advertised as working correctly. The changes are also aligned with vscode which perform similar checks.The pull-request includes:
engines.vscode
propertyvsx-editor
to display the version (similarly to vscode)How to test
For test purposes, the prettier extension was used:
engines.vscode
VSCODE_DEFAULT_API
5.0.1
^1.41.0
(link)1.44.0
3.20.0
^1.34.0
(link)1.40.0
1.20.0
VSCODE_API_VERSION
(1.40.0) and rebuild the changesVSCODE_API_VERSION
(1.20.0) and rebuild the changesReview checklist
Reminder for reviewers