Repository navigation
[flutter_svg] Evict failed pending loads and avoid unhandled cache errors - #13613
Open
deandreamatias wants to merge 1 commit into
Open
deandreamatias wants to merge 1 commit into
deandreamatias wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request modifies the Cache class in flutter_svg to handle loader failures by adding an onError handler to the pending loader future. This ensures that a failed loader is evicted from the pending map, allowing subsequent retries, and verifies that the pending loader is identical to the current pending result before removal. A unit test has been added to verify this behavior. There are no review comments, and I have no feedback to provide.
11 tasks done
auto-submit Bot
pushed a commit
that referenced
this pull request
Nov 11, 2026
…3595) Rebased on current main (`8041ccab1`), preserving the failed-load fix and its regression test from #13604. This PR adds invalidation of pending loads on `Cache.clear` and `Cache.evict`: an obsolete completion cannot repopulate the cache or remove a replacement request, even when loaders reuse the same Future. Documents pending-load invalidation on both methods. The cache lifecycle tests live in `cache_test.dart`. The shared-Future regression checks that an evicted request does not populate the cache before the replacement's completion callback runs. Preserves synchronous cache hits, coalescing and entry-count LRU. Bumps the package to 2.3.4 with a changelog entry. Related: flutter/flutter#182486 (failed-load cleanup is already on main via #13604). Validation on Windows: `flutter analyze` clean; full `flutter test` suite: 77 passed, 1 existing skip; formatting and `git diff --check` passed. No golden files changed. Overlapping proposals: #13613 also concerns failed pending loads; main already includes #13604. This PR retains that fix and focuses on clear/evict invalidation. #13596 is stacked on this branch and was rebased with it. ## Pre-Review Checklist This draft was prepared with AI assistance and remains pending the contributor's human review and confirmation of the unchecked checklist items.
11 tasks done
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.
Fixes flutter/flutter#196285
A transient network failure in
SvgPicture.network(for example, anhttp.ClientException) can escape from a derived future inCache.putIfAbsentand reachPlatformDispatcher.onError. The widget'serrorBuilderruns, but it does not expose the escaped future, so applications cannot catch it and Crashlytics may record it as a fatal error.Handle errors on the derived future and evict the failed pending entry, allowing later calls for the same key to retry. The error handler does not swallow the caller's error: the future returned by
putIfAbsentstill completes with the original error.Add a regression test that verifies the original error reaches the caller and a subsequent load for the same key is retried.
Related: dnfield/flutter_svg#881
Related PR: dnfield/flutter_svg#1104
Validation
dart format lib testflutter analyze(no issues)flutter test test/cache_test.dart(all tests passed)