Skip to content

Conversation

@cklin
Copy link
Contributor

@cklin cklin commented Jan 30, 2026

The activation test was failing intermittently on Windows CI because it used a hardcoded 4-second delay after opening a .ql file to wait for the extension to activate. On slower machines, this wasn't enough time.

Replace the fixed delay with a polling loop that checks ext.isActive every 100ms for up to 30 seconds. This ensures the test:

  • Returns quickly on fast machines
  • Doesn't fail prematurely on slow machines

The activation test was failing intermittently on Windows CI because it used
a hardcoded 4-second delay after opening a .ql file to wait for the extension
to activate. On slower machines, this wasn't enough time.

Replace the fixed delay with a polling loop that checks ext.isActive every
100ms for up to 30 seconds. This ensures the test:
- Returns quickly on fast machines
- Doesn't fail prematurely on slow machines
@cklin cklin marked this pull request as ready for review January 30, 2026 17:38
@cklin cklin requested a review from a team as a code owner January 30, 2026 17:38
@cklin cklin requested review from Copilot and ginsbach January 30, 2026 17:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a flaky activation test that was failing intermittently on Windows CI by replacing a hardcoded 4-second delay with a polling approach that checks for extension activation up to 30 seconds.

Changes:

  • Replaced fixed delay() calls with a new waitForActivation() function that polls extension status
  • Implemented polling logic with 100ms intervals and 30-second timeout

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return;
}
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The waitForActivation function should throw an error if the extension fails to activate within the timeout period. Currently, if the timeout is reached without activation, the function returns silently, and the test will fail on the subsequent assertion at line 27 with a less informative error message. Consider throwing a descriptive error after the loop completes to make timeout failures clearer and easier to diagnose.

Suggested change
}
}
throw new Error(
`Extension "GitHub.vscode-codeql" did not activate within ${timeoutMs} ms.`,
);

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +37
const pollIntervalMs = 100;
const maxAttempts = timeoutMs / pollIntervalMs;
for (let i = 0; i < maxAttempts; i++) {
if (extension!.isActive) {
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The non-null assertion operator on 'extension' (line 37) assumes the parameter is always defined, but the parameter type 'typeof ext' can be 'Extension | undefined'. Consider adding a check at the beginning of the function to validate that extension is defined, or update the function signature to ensure extension cannot be undefined.

Suggested change
const pollIntervalMs = 100;
const maxAttempts = timeoutMs / pollIntervalMs;
for (let i = 0; i < maxAttempts; i++) {
if (extension!.isActive) {
if (!extension) {
throw new Error("Extension is not defined.");
}
const pollIntervalMs = 100;
const maxAttempts = timeoutMs / pollIntervalMs;
for (let i = 0; i < maxAttempts; i++) {
if (extension.isActive) {

Copilot uses AI. Check for mistakes.
timeoutMs: number,
): Promise<void> {
const pollIntervalMs = 100;
const maxAttempts = timeoutMs / pollIntervalMs;
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The calculation 'timeoutMs / pollIntervalMs' on line 35 may result in a non-integer value if timeoutMs is not evenly divisible by pollIntervalMs. While the for loop will handle this by truncating to an integer, it means the actual timeout may be shorter than intended. Consider using 'Math.ceil(timeoutMs / pollIntervalMs)' to ensure the full timeout duration is respected.

Suggested change
const maxAttempts = timeoutMs / pollIntervalMs;
const maxAttempts = Math.ceil(timeoutMs / pollIntervalMs);

Copilot uses AI. Check for mistakes.
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.

5 participants