Prefetch files when downloading archive - #2855
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughBackup downloads now support bounded concurrent prefetching, retryable entry opening, progress updates, and improved CLI HTTP errors. The dashboard exposes a copyable CLI download command and conditionally retains backup deletion. ChangesBackup download flow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant downloadBackupArchive
participant prefetchEntries
participant openWithRetry
participant ArchiveWriter
downloadBackupArchive->>prefetchEntries: provide deferred entry specifications
prefetchEntries->>openWithRetry: open entry bodies with retry
openWithRetry-->>prefetchEntries: return prepared entry bodies
prefetchEntries-->>downloadBackupArchive: yield entries in order
downloadBackupArchive->>ArchiveWriter: write archive entry
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View Vercel preview at instant-www-js-prefetch-downloads-jsv.vercel.app. |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@client/packages/cli/src/lib/backupDownload.ts`:
- Around line 63-69: Update the chunk accumulation loop in the backup download
flow to enforce the 2 KiB limit before appending data. In the loop over res,
calculate the remaining budget, slice the current chunk to that size, append
only the sliced portion, update total accordingly, and stop once the limit is
reached.
- Around line 61-79: Update readErrorBody to accept and use the request’s
AbortSignal or an internally enforced finite timeout while reading the response,
ensuring partial error bodies cannot block indefinitely. Preserve abort errors
instead of swallowing them in the catch block, while retaining the existing
empty-string fallback for other read failures and cleanup via res.destroy().
In `@client/packages/platform/src/backupDownload.ts`:
- Around line 321-326: Normalize the retry and prefetch options before use: in
the retry setup around retryAttempts and retryDelayMs, accept attempts only when
it is a finite positive integer, otherwise use DEFAULT_FETCH_ATTEMPTS; normalize
delayMs to a finite non-negative number, otherwise use DEFAULT_RETRY_DELAY_MS.
Apply the same finite positive-integer validation to prefetch, falling back to
its existing default when invalid, so NaN and Infinity cannot alter retry or
pipeline bounds.
- Around line 94-105: Extend openWithRetry and the body-consumption flow so
failures encountered before the first yielded chunk trigger a fresh fetch/retry,
including streams returned by fetchBody that fail on their first read. Track
whether writer.add has received any chunk; propagate errors after the first
chunk as unrecoverable mid-stream failures. Add coverage for a fetchBody result
whose first read errors.
In `@client/www/components/dash/Backups.tsx`:
- Around line 262-268: Update copyCliDownloadCommand to support non-secure HTTP
origins by either requiring HTTPS before using navigator.clipboard.writeText or,
preferably, providing a manual-copy fallback when the Clipboard API is
unavailable or fails. Preserve the success toast when copying succeeds and show
the failure toast only when both automatic and fallback copying cannot be
completed.
- Around line 250-260: Update the cliDownloadCommand construction to POSIX-shell
quote the dynamic config.apiURI, backup.id, and app.id values before
interpolation, including the INSTANT_CLI_API_URI assignment, while preserving
the existing production-backend omission behavior. Do not add alternate shell
formats unless this command explicitly supports PowerShell or cmd.exe.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e9ee21d8-2e1e-4369-b86d-3623ff8b4987
📒 Files selected for processing (4)
client/packages/cli/src/lib/backupDownload.tsclient/packages/platform/__tests__/src/backupDownload.test.tsclient/packages/platform/src/backupDownload.tsclient/www/components/dash/Backups.tsx
A few fixes and improvements for downloading backups: