fix/fallback#520
Merged
Merged
Conversation
❌ Test Failures on
|
Comment on lines
147
to
155
| select { | ||
| case <-dlCtx.Done(): | ||
| return dlCtx.Err() | ||
| case <-time.After(ra): | ||
| } | ||
| if d.State != nil { | ||
| d.State.RateLimited.Store(false) | ||
| } | ||
| continue |
Contributor
There was a problem hiding this comment.
RateLimited flag not cleared on context cancellation
When the parent context is cancelled (e.g., user pauses or aborts) while the downloader is waiting out the rate-limit backoff, dlCtx.Done() fires and the function returns dlCtx.Err() at line 149 — skipping the RateLimited.Store(false) call at lines 152-154. The flag remains true in the shared ProgressState, so the TUI will continue showing "Rate limited, retrying…" even after the download has stopped. Adding defer d.State.RateLimited.Store(false) alongside the existing defer d.State.ActiveWorkers.Store(0) block (around line 86) would clean this up unconditionally on function exit.
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/engine/single/downloader.go
Line: 147-155
Comment:
**`RateLimited` flag not cleared on context cancellation**
When the parent context is cancelled (e.g., user pauses or aborts) while the downloader is waiting out the rate-limit backoff, `dlCtx.Done()` fires and the function returns `dlCtx.Err()` at line 149 — skipping the `RateLimited.Store(false)` call at lines 152-154. The flag remains `true` in the shared `ProgressState`, so the TUI will continue showing "Rate limited, retrying…" even after the download has stopped. Adding `defer d.State.RateLimited.Store(false)` alongside the existing `defer d.State.ActiveWorkers.Store(0)` block (around line 86) would clean this up unconditionally on function exit.
How can I resolve this? If you propose a fix, please make it concise.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Greptile Summary
This PR adds rate-limit awareness to the single-threaded downloader: it reads the
Retry-Afterheader on HTTP 429/503 responses, waits out the backoff, and surfaces "Rate limited, retrying…" in the TUI instead of silently stalling. A newRateLimited atomic.Boolis threaded fromProgressStatethroughProgressMsgtoDownloadModel.RateLimited atomic.BooltoProgressState(reset inSessionReset) and propagates it viaProgressMsg→DownloadModelto drive a new TUI display branch.SingleDownloader.Download(), toggling the flag before/after the backoff sleep with context-aware cancellation support.view.go, inserted correctly before the genericpaused/zero-speed branch.Confidence Score: 3/5
Mostly safe, but the RateLimited flag is not cleared when the download is paused or cancelled mid-backoff, leaving the TUI stuck on "Rate limited, retrying…" after the download stops.
The backoff cancel path in downloader.go returns dlCtx.Err() before reaching the RateLimited.Store(false) call. Any pause or abort while the downloader is sleeping will leave the flag set indefinitely, since there are no further progress messages to clear it and SessionReset is only called on a full restart.
internal/engine/single/downloader.go — the rate-limit backoff cancel path needs a defer to clear the RateLimited flag on function exit.
Important Files Changed
RateLimited atomic.BooltoProgressStateand resets it inSessionReset(); implementation is clean and consistent with the existing atomic fields pattern.RateLimited booltoProgressMsg; straightforward struct field addition with no issues.cfg.State.RateLimited.Load()into the outgoingProgressMsg; correct and minimal change.rateLimited boolfield toDownloadModel; alignment-only formatting change alongside the new field.msg.RateLimitedintod.rateLimitedduring progress processing; correct single-line change.RateLimitedis not cleared on cancellation (see downloader.go finding).Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "Merge branch 'main' into fix/fallback" | Re-trigger Greptile