Skip to content

Clean up WaitForSessionFile logic and support increasing timeout with warning #2653

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

Merged

Conversation

TylerLeonhardt
Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Apr 22, 2020

PR Summary

fixes #2526

This does 3 things:

  • ups the time out to 120 attempts * 2sec between each = 4min
  • exposes powershell.developer.waitForSessionFileNumOfTries to modify the 120 value
  • warns the user after waitForSessionFileNumOfTries/2 to say "this shouldn't be happening"
  • cleans up the code to use promises/async/await instead of callbacks

Note: I needed to move this function from utils.ts into process.ts because utils.ts is also used in debugAdapter.ts which can't use the vscode node_module.

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets.
Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
  • Summarized changes
  • PR has tests - how?
  • This PR is ready to merge and is not work in progress
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready

Copy link
Contributor

@rjmholt rjmholt left a comment

Choose a reason for hiding this comment

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

Really like this implementation. The code looks good, but just want to go over the details of the settings before we merge

package.json Outdated
@@ -761,6 +761,11 @@
"default": null,
"description": "An array of strings that enable experimental features in the PowerShell extension."
},
"powershell.developer.waitForSessionFileNumOfTries": {
Copy link
Contributor

Choose a reason for hiding this comment

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

As a setting I think it would make more sense to expose a timeout and then in the implementation just retry until the total exceeds the timeout

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that. Perhaps powershell.developer.sessionStartupTimeout?

src/process.ts Outdated
return reject(error);
}
// This is used to warn the user that the extension is taking longer than expected to startup.
const warnUserThreshold = numOfTries / 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

For the warning, I'd imagine our standard expectation for startup time is a constant, like 30 seconds, rather than parameterised by the setting

return new Promise(resolve => setTimeout(resolve, ms));
}

private async waitForSessionFile(): Promise<utils.IEditorServicesSessionDetails> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you! We've been using async/await in our Electron/Angular app code base and vastly prefer it to dealing with Promises directly. :-)

Copy link
Contributor

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

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

LGTM other than I like the suggestion to switch to a timeout setting instead of numTries.

@TylerLeonhardt
Copy link
Member Author

Moved to seconds in the timeout, also changed the warning to call out "privilege enforcement software" as that seems to be the culprit in the issue.

@TylerLeonhardt TylerLeonhardt merged commit 7dadd34 into PowerShell:master Apr 23, 2020
@TylerLeonhardt TylerLeonhardt deleted the add-better-try-sessionfile branch August 10, 2020 15:05
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.

The Language Service Could not be started
3 participants