-
Notifications
You must be signed in to change notification settings - Fork 53
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
Conversation
try .. finally
to always reset debounce statetry ... finally
to always reset debounce state
c07319f
to
1246edc
Compare
restartQueued = false; | ||
await runServer(); | ||
if (restartQueued) { | ||
restartQueued = false; |
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 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.
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'm confused a bit. Can you expand in which case it could be false
? I'm unable to follow here.
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.
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).
1246edc
to
382286f
Compare
## 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
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.