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

feat(lsp): upgrade check on init and notification #21105

Merged
merged 12 commits into from
Nov 14, 2023

Conversation

nayeemrmn
Copy link
Collaborator

@nayeemrmn nayeemrmn commented Nov 7, 2023

Coupled with denoland/vscode_deno#988.

There's not much to unit test and an integration test isn't feasible. You can manually test by rolling back the version in cli/Cargo.toml, building, launching post-patch vscode_deno against that binary and clicking the status bar.

@nayeemrmn nayeemrmn changed the title feat(lsp): add "deno/denoUpgradeAvailable" notification feat(lsp): add "deno/upgradeAvailable" request Nov 7, 2023
@nayeemrmn nayeemrmn changed the title feat(lsp): add "deno/upgradeAvailable" request feat(lsp): upgrade check on init and notification Nov 7, 2023
cli/lsp/language_server.rs Outdated Show resolved Hide resolved
Comment on lines 242 to 248
pub async fn check_for_upgrades_for_lsp(
http_client: Arc<HttpClient>,
) -> Result<Option<(String, bool)>, AnyError> {
let is_canary = version::is_canary();
let latest_version;
let mut is_upgrade;
if is_canary {
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be checking for new version unconditionally - we should reuse logic from check_for_upgrades that checks for DENO_NO_UPDATE_CHECK as well as checks only once every few hours. That will also allow us to unit test this functionality.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The env var check is at the call site. We can't reuse the cooldown logic because we have to know if there is or isn't an update available every time the LSP is connected to so that status shown in the extension is accurate.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, but can we do it in a task that doesn't block the LSP from starting up? It appears currently this is done serially and the LSP waits for the update check to finish.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It appears currently this is done serially and the LSP waits for the update check to finish.

Nope it's done in the initialized notification handler and outside of the LS lock. initialized is responseless, the client will treat the server as ready after just sending it.

Copy link
Member

@dsherret dsherret Nov 13, 2023

Choose a reason for hiding this comment

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

Maybe it would be good to update or add a test that uses a url on the test server that will cause a hang for say 20 seconds? Then the test could assert it took less than 20 seconds? It would help in case there's ever a regression.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems like it's really complicated to embed test URLs in the LSP without a public API (e.g. NPM_CONFIG_REGISTRY). The LSP test harness for some reason (sometimes?) spawns a server with the non-test binary so conditional compilation is weird. Doesn't seem worth it

Copy link
Member

Choose a reason for hiding this comment

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

The LSP test harness for some reason (sometimes?) spawns a server with the non-test binary so conditional compilation is weird.

Were you running cargo build after making changes to the test server?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Were you running cargo build after making changes to the test server?

I don't thinks so. Maybe it would work if I built test_util most recently with cargo test test_util, but... yeah. I think in the future we can make more of the language server centre unit testable.

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

I believe this will output when the repl doesn't have internet connection, but otherwise it's looking good.

cli/lsp/language_server.rs Outdated Show resolved Hide resolved
cli/lsp/language_server.rs Outdated Show resolved Hide resolved
cli/lsp/language_server.rs Outdated Show resolved Hide resolved
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM!

@nayeemrmn nayeemrmn merged commit 4913274 into denoland:main Nov 14, 2023
13 checks passed
@nayeemrmn nayeemrmn deleted the lsp-upgrade-available-notification branch November 15, 2023 01:20
zifeo pushed a commit to metatypedev/deno that referenced this pull request Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants