Skip to content

Fix startup timeout after adjusting sleeps #5199

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
merged 1 commit into from
May 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import { Settings, validateCwdSetting } from "./settings";
import utils = require("./utils");

export class PowerShellProcess {
// This is used to warn the user that the extension is taking longer than expected to startup.
private static warnUserThreshold = 30;

private static title = "PowerShell Extension";

public onExited: vscode.Event<void>;
Expand Down Expand Up @@ -282,9 +279,9 @@ export class PowerShellProcess {
private async waitForSessionFile(
cancellationToken: vscode.CancellationToken,
): Promise<IEditorServicesSessionDetails | undefined> {
const numOfTries =
this.sessionSettings.developer.waitForSessionFileTimeoutSeconds;
const warnAt = numOfTries - PowerShellProcess.warnUserThreshold;
const numOfTries = // We sleep for 1/5 of a second each try
5 * this.sessionSettings.developer.waitForSessionFileTimeoutSeconds;
const warnAt = numOfTries - 5 * 30; // Warn at 30 seconds
Comment on lines +283 to +284
Copy link
Preview

Copilot AI May 22, 2025

Choose a reason for hiding this comment

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

[nitpick] Replace magic numbers (5 and 30) with named constants (e.g., retriesPerSecond and warnThresholdSeconds) to clarify their purpose.

Suggested change
5 * this.sessionSettings.developer.waitForSessionFileTimeoutSeconds;
const warnAt = numOfTries - 5 * 30; // Warn at 30 seconds
PowerShellProcess.retriesPerSecond * this.sessionSettings.developer.waitForSessionFileTimeoutSeconds;
const warnAt = numOfTries - PowerShellProcess.retriesPerSecond * PowerShellProcess.warnThresholdSeconds; // Warn at 30 seconds

Copilot uses AI. Check for mistakes.


// Check every second.
this.logger.writeDebug(
Expand Down Expand Up @@ -314,7 +311,7 @@ export class PowerShellProcess {
);
}

// Wait a bit and try again.
// Wait 1/5 of a second and try again
await utils.sleep(200);
}

Expand Down
Loading