fix(vscode-extension): add robust error handling, retries, and logging to extension updater (#1158) - #1272
Conversation
|
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. |
📋 GSSoC Label Validation Report✅ All label requirements met. This PR passes the pre-merge label check. 📖 Label Reference
|
There was a problem hiding this comment.
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) andfetchWithRetry(retry/backoff) helpers and refactored update checks/downloads to use them. - Hardened update flow: validates downloaded VSIX is non-empty, logs failures, shows
showWarningMessageon 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.
| 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, | ||
| }); |
| const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {}); | ||
|
|
||
| await checkForUpdates(mockContext); | ||
|
|
| try { | ||
| if (fs.existsSync(vsixPath)) { | ||
| await fs.promises.unlink(vsixPath); | ||
| } |
|
🚨 Hey @Rakshak05, the CI Pipeline is failing on this PR and it has been marked as 🔍 What failed:
📋 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 passes2. Auto-fix common issues: npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
Ixotic27
left a comment
There was a problem hiding this comment.
LGTM! Verified and approved. Great contribution!
Ixotic27
left a comment
There was a problem hiding this comment.
LGTM! Approved and verified. Great contribution!
|
🎉 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.
Keep building! 💻✨ |
What does this PR do?
Improves error handling, network resiliency, and logging in the VSCode extension updater (
packages/vscode-extension/src/updater.ts):fetchWithTimeoutusingAbortControllerandtry...finallyto ensure timeout timers are always cleared cleanly.fetchWithRetryto handle transient network rejections, timeouts, and non-200 HTTP statuses with configurable retries and backoff.downloadFileto validate downloaded buffer length (> 0 bytes) and handle disk writing errors gracefully.checkForUpdatesto 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..vsixdownload files are cleaned up in afinallyblock and the debounce timestamp (leetcodecity.lastUpdateCheck) is updated ONLY upon a successful check or installation.packages/vscode-extension/src/updater.test.ts.Related issue
Fixes #1158
Screenshots
N/A (Background updater logic and extension error handling)
Checklist
npm run lintpasses