Repository navigation
fix: clear a running resize when its listener cancels - #553
Open
nilsreichardt wants to merge 1 commit into
Open
nilsreichardt wants to merge 1 commit into
nilsreichardt wants to merge 1 commit into
Conversation
getImageFile removed the shared resize stream only after yield* had completed. A listener that cancelled, for example on a download error, skipped that line, so the next call for the same url and size got the finished stream and ended without a file or an error. Fixes Baseflow#439 Co-Authored-By: Claude <noreply@anthropic.com>
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.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Bug fix.
getImageFilewithmaxWidthormaxHeightshares one stream per resized key through_runningResizesand removes it afteryield*. When a listener cancels, for example at a download error, the generator stops at theyield*and never reaches that line. The finished stream stays in the map, so the next call for the same url and size ends without a file or an error.With
CachedNetworkImagethe image then stays on its placeholder until the app restarts. Flutter'sImageCachekeeps the completer that never completes and hands it to every later widget for that image.🆕 What is the new behavior (if this is a feature change)?
The stream is removed in a
finally, so a cancelled listener cleans it up too. The next call downloads the image again.💥 Does this PR introduce a breaking change?
No
🐛 Recommendations for testing
The new test fails on
mainwithBad state: No elementand passes with the fix.flutter analyzeand the fullflutter testsuite pass.📝 Links to relevant issues/docs
Fixes #439. Also reported as Baseflow/flutter_cached_network_image#901 and Baseflow/flutter_cached_network_image#980.
#548 also moves this cleanup into a
finallyas part of per-caller cancellation. This PR is the minimal fix for the current code.🤔 Checklist before submitting
🤖 Generated with Claude Code