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

Use try ... finally to always reset debounce state #558

Merged
merged 1 commit into from
Jul 24, 2024
Merged

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Jul 24, 2024

Summary

This PR is a refactor to use try .. finally in the logic which starts the server to always reset the debounce state variable (restartInProgress). This is to ensure that it's always reset even in case of a failure.

Test Plan

Refer to the test plan in #559.

@dhruvmanila dhruvmanila changed the title Use try .. finally to always reset debounce state Use try ... finally to always reset debounce state Jul 24, 2024
@dhruvmanila dhruvmanila marked this pull request as ready for review July 24, 2024 15:12
restartQueued = false;
await runServer();
if (restartQueued) {
restartQueued = false;
Copy link
Member

Choose a reason for hiding this comment

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

I think we might still need to set restartInProgress to false before calling into runServer or the function will exit early. The alternative is to split the function even more: One with the restartInProgress check (e.g. debouncedRestartServer and one without.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm confused a bit. Can you expand in which case it could be false? I'm unable to follow here.

Copy link
Member Author

Choose a reason for hiding this comment

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

The queued restart block has been moved into the finally block where it should've been which resolves the race condition I was hitting (shared on Discord).

@dhruvmanila dhruvmanila merged commit 08a567f into main Jul 24, 2024
6 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/finally branch July 24, 2024 19:32
dhruvmanila added a commit that referenced this pull request Jul 24, 2024
## Summary

Follow-up to #558

This PR separates the server start and stop logic.

This is required because the extension could skip starting the server in
the following cases:
1. No Python interpreter is selected
2. Python extension is unable to resolve the environment for the given
Python interpreter
3. Python version is incompatible

So, if the extension was already running and the settings were updated
to hit any one of the above cases, the server would still be running
(not ideal).

## Test Plan

Here, the diagnostics should disappear because the server stopped first
before checking for the interpreter.

For (1),

I'd need to uninstall all Python versions for me to reproduce this so
I'm skipping this scenario assuming that (2) and (3) is sufficient.

For (2),


https://github.com/user-attachments/assets/124ab434-c082-4e67-a606-24040d8f04a8

For (3),


https://github.com/user-attachments/assets/2300ee88-01be-45be-9c03-ae2ff4aeda78
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.

2 participants