Skip to content

fix(vscode-extension): add robust error handling, retries, and logging to extension updater (#1158) - #1272

Merged
Ixotic27 merged 18 commits into
Ixotic27:mainfrom
Rakshak05:issue-#1158
Aug 5, 2026
Merged

fix(vscode-extension): add robust error handling, retries, and logging to extension updater (#1158)#1272
Ixotic27 merged 18 commits into
Ixotic27:mainfrom
Rakshak05:issue-#1158

Conversation

@Rakshak05

Copy link
Copy Markdown
Contributor

What does this PR do?

Improves error handling, network resiliency, and logging in the VSCode extension updater (packages/vscode-extension/src/updater.ts):

  • Added fetchWithTimeout using AbortController and try...finally to ensure timeout timers are always cleared cleanly.
  • Added fetchWithRetry to handle transient network rejections, timeouts, and non-200 HTTP statuses with configurable retries and backoff.
  • Refactored downloadFile to validate downloaded buffer length (> 0 bytes) and handle disk writing errors gracefully.
  • Enhanced checkForUpdates to log detailed diagnostic messages (console.warn("[LeetCode City Updater] ...")) and display warning messages (vscode.window.showWarningMessage) when update downloads/installations fail during an active update attempt.
  • Ensured temporary .vsix download files are cleaned up in a finally block and the debounce timestamp (leetcodecity.lastUpdateCheck) is updated ONLY upon a successful check or installation.
  • Added comprehensive unit tests in packages/vscode-extension/src/updater.test.ts.

Related issue

Fixes #1158

Screenshots

N/A (Background updater logic and extension error handling)

Checklist

  • npm run lint passes
  • Tested locally
  • No secrets or .env values committed
  • I acknowledge that an automated AI Reviewer will perform a preliminary review of this PR.
  • I have starred this repository!

Copilot AI review requested due to automatic review settings August 2, 2026 07:05
@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the ixotic27-8245's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

📋 GSSoC Label Validation Report

All label requirements met. This PR passes the pre-merge label check.


📖 Label Reference
Category Valid Labels Rules
Approval gssoc:approved Required to score and merge
Difficulty level:beginner / intermediate / advanced / critical Exactly one is required
Quality quality:clean / quality:exceptional Optional (max one); exceptional requires reviewer comment
Type type:bug, type:feature, type:docs, type:testing, type:refactor, type:design, type:accessibility, type:performance, type:devops, type:security At least one is required
Blocking gssoc:invalid, gssoc:spam, gssoc:ai-slop Excludes PR from scoring and blocks merge

@github-actions github-actions Bot added good first issue Good for newcomers Gssoc 26 Part of GirlScript Summer of Code 2026 gssoc:approved Approved GSSoC contribution level:beginner Beginner difficulty level type:bug Something isn't working as expected labels Aug 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Security Scan: Clean

No suspicious patterns detected. The official Copilot bot will provide detailed AI feedback shortly.

If you enjoyed contributing, please consider starring the repository!

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Aug 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves the VS Code extension self-updater by adding timeout + retry wrappers around fetch, strengthening download validation/cleanup, and adding diagnostic logging + user-facing warnings so update failures no longer fail silently (addressing #1158).

Changes:

  • Added fetchWithTimeout (AbortController-based) and fetchWithRetry (retry/backoff) helpers and refactored update checks/downloads to use them.
  • Hardened update flow: validates downloaded VSIX is non-empty, logs failures, shows showWarningMessage on update attempt failure, and always best-effort cleans up temp VSIX files.
  • Added Vitest unit coverage for semver comparison, timeout/retry wrappers, download validation, and updater behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/vscode-extension/src/updater.ts Introduces fetch timeout/retry helpers and refactors the updater flow with better logging, validation, and cleanup.
packages/vscode-extension/src/updater.test.ts Adds unit tests covering updater helpers and key update flow scenarios (success, debounce, failures).

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

Comment on lines 34 to +40
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 30000); // 30s timeout for download

const res = await (globalThis as any).fetch(url, { signal: controller.signal });
clearTimeout(timeoutId);
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
try {
const res = await (globalThis as any).fetch(url, {
...options,
signal: controller.signal,
});
Comment on lines +226 to +229
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});

await checkForUpdates(mockContext);

Comment on lines +180 to +183
try {
if (fs.existsSync(vsixPath)) {
await fs.promises.unlink(vsixPath);
}
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Aug 2, 2026
@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Aug 2, 2026
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

🚨 Hey @Rakshak05, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

🔍 What failed:

  • Production Build failed at step(s): Run Production Build

📋 Error Details (first 2):

Please fix the issues before this can be reviewed. Here's how:

1. Run checks locally before pushing:

npm run lint           # Run ESLint
npm run build          # Verify production build passes

2. Auto-fix common issues:

npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Aug 2, 2026
@Ixotic27 Ixotic27 added the quality:clean Code is clean, well-tested, and adheres to all guidelines. label Aug 5, 2026

@Ixotic27 Ixotic27 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM! Verified and approved. Great contribution!

@Ixotic27 Ixotic27 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM! Approved and verified. Great contribution!

@Ixotic27
Ixotic27 merged commit 1449db7 into Ixotic27:main Aug 5, 2026
8 of 9 checks passed
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🎉 Congratulations @Rakshak05! Your PR has been successfully merged. 🚀

Thank you for contributing to The Leetcode City. Your work helps us build a better platform for the community.

⚠️ Important for GSSoC Contributors:
Please make sure you are following all contribution guidelines. All important announcements and point claims happen through the official GSSoC channels.

Keep building! 💻✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue Good for newcomers gssoc:approved Approved GSSoC contribution Gssoc 26 Part of GirlScript Summer of Code 2026 level:beginner Beginner difficulty level quality:clean Code is clean, well-tested, and adheres to all guidelines. type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: VSCode extension updater fails silently / lacks robust error handling (packages/vscode-extension/src/updater.ts)

3 participants