This repository was archived by the owner on Oct 23, 2026. It is now read-only.
Repository navigation
feat(upgrade): progress bars for delta-patch apply and full download - #1281
Merged
Merged
Conversation
`sentry upgrade` currently gives no feedback during the slow phases. Adds two byte-driven progress bars, gated on interactive output (isPlainOutput()), so they self-suppress under NO_COLOR, piped stdout, and CI. - Apply phase: a determinate bar in applyChainAndReturn. Total is the final binary size (the last patch's declared newSize), so the number shown is the real output the user gets — not the sum of intermediate hop writes. Progress is byte-driven across all hops via an onBytes callback threaded through applyReaderToMemory/applyReaderToFile -> applyPatchChainInMemory -> applyPatchChain, so the bar advances smoothly through the whole chain. - Full-binary download: an indeterminate byte counter in streamDecompressToFile. The decompressed size isn't known ahead of time (Content-Length covers only the compressed stream), so it shows a live byte count rather than a fake fraction. New src/lib/progress.ts (makeByteProgress): reuses the existing formatBytes and isPlainOutput helpers; cosmetic-only — a render failure never aborts the upgrade, and both onProgress and done() are guarded against throwing streams. Tests (test/lib/progress.test.ts, 7): determinate/indeterminate rendering, plain-output and non-TTY header-only behavior, byte accumulation, full-bar clamping, and the never-throws contract — mutation-verified: an unguarded done() turns the never-throws test RED.
Contributor
|
Contributor
Codecov Results 📊✅ Patch coverage is 90.32%. Project has 5489 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.69% 81.71% +0.02%
==========================================
Files 426 427 +1
Lines 29971 30018 +47
Branches 19499 19513 +14
==========================================
+ Hits 24485 24529 +44
- Misses 5486 5489 +3
- Partials 2045 2046 +1Generated by Codecov Action |
Three fixes from Cursor Bugbot + Seer review of #1281: 1. Multi-hop apply bar total (Seer, medium): onBytes fires for the output bytes of EVERY hop — intermediate in-memory hops and the final disk write — so the bar total must be the SUM of all hops' newSize, not just the final binary's. The last-hop-only total made a multi-patch bar hit 100% after hop 1 and freeze. applyChainAndReturn now sums parsePatchHeader(p).newSize across all patches. 2. Progress not cleared on download failure (Bugbot, medium): streamDecompressToFile called progress.done() after the writer.end await in finally, so a rejecting end (ENOSPC/EIO) skipped it, leaving a stale bar merged into the error output. Wrapped the body in an outer try/finally so done() always runs. 3. Stale characters on shorter redraws (Bugbot, low): interactive redraws now pad the new frame with spaces to the previous frame's width, so a shrinking line (e.g. KB→MB boundary) can't leave leftover tail characters. Tests: bspatch onBytes test asserts a 2-hop chain reports sum of both hops' newSize (mutation-verified: dropping onBytes on in-memory hops → RED); progress test asserts a shorter redraw is padded to erase the tail (mutation-verified: removing the padding → RED).
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9c039ad. Configure here.
Addresses two review findings on the progress bars:
1. Progress bars clash with the upgrade spinner (Cursor, medium): the main
`sentry upgrade` path runs under withProgress, which animates a spinner on
the same terminal line. A second in-place byte bar on stderr fought with it,
making both unreadable. Reworked so progress feeds the spinner's setMessage
callback instead of drawing its own bar — one animation, no clash. The
setMessage is threaded from withProgress through executeUpgrade ->
downloadBinaryToTemp -> {tryDeltaUpgrade -> attemptDeltaUpgrade ->
resolve*Delta -> applyChainAndReturn, downloadFullBinary -> download*ToPath
-> streamDecompressToFile}. When absent (JSON mode / non-TTY) it's a no-op.
2. writer.end() error masks the original stream error (Seer, medium): in
streamDecompressToFile a rejection from writer.end() in the finally could
overwrite the root-cause streaming error. Restructured so the original
stream error is captured and rethrown preferentially; an end() failure that
follows it is demoted to a debug log.
progress.ts is now a throttled message formatter (determinate bar with % or an
indeterminate byte counter) rather than a stream writer. Cosmetic-only: a
formatting/callback failure never propagates.
Tests: progress.test.ts rewritten for the setMessage API (7) — determinate/
indeterminate formatting, accumulation + clamp, throttling, final done() emit,
no-op without setMessage, never-throws. Mutation-verified: removing the emit
try/catch → never-throws RED; removing the throttle → throttle RED.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
sentry upgradegives no feedback during its slow phases. This adds two byte-driven progress bars.Applying 3 patch(es) [███████░░░░░░░░░] 22.1 MB / 45.0 MB. Total is the final binary size (the last patch's declarednewSize), i.e. the real output the user gets — not the sum of intermediate hop writes. Progress is byte-driven across the whole chain, so it advances smoothly rather than stalling per hop.Downloading 38.0 MB. The decompressed size isn't known ahead of time (Content-Lengthcovers only the compressed stream), so it shows an honest live byte count, not a fake fraction.Both bars are gated on interactive output via the existing
isPlainOutput(), so they self-suppress underNO_COLOR, piped stdout, and CI.How
src/lib/progress.ts—makeByteProgress(label, totalBytes). Reuses the existingformatBytes(formatters/numbers) andisPlainOutput(formatters/plain-detect) helpers. Cosmetic-only: a render failure never aborts the upgrade, and bothonProgressanddone()are guarded against throwing streams.onBytescallback is threaded throughapplyReaderToMemory/applyReaderToFile→applyPatchChainInMemory→applyPatchChain, reporting bytes-written per output chunk. Purely additive — no behavior change to the apply/verify logic.applyChainAndReturn; download bar instreamDecompressToFile.Tests
test/lib/progress.test.ts(7): determinate/indeterminate rendering, plain-output and non-TTY header-only behavior, byte accumulation, full-bar clamping, and the never-throws contract — mutation-verified: an unguardeddone()turns the never-throws test RED.Verification
progress+bspatch) pass,tsc --noEmitclean,biome checkclean.MAX_OUTPUT_SIZE) and perf(upgrade): vectorize bspatch diff-add with SWAR (4x faster apply) #1280 (SWAR) — separate file regions, no overlap.