Repository navigation
fix(image cache): add HTTP timeout to network image preview download - #343
Merged
sparkleMing merged 1 commit intoJul 24, 2026
Merged
Conversation
The image preview cache holds a single process-wide _previewLock around the whole download+compress in _createPreviewFile. The http.get call had no timeout, so a hung or blackholed remote image URL held the lock indefinitely and blocked every other preview — including local-file previews and LocalAssetServer requests that back the WebView. Adds a 20 s timeout and surfaces it as ImagePreviewUnavailable so the existing error handling reports it consistently. Broader question of sharding the lock per cache key is intentionally out of scope.
PR AI Review / PR AI 语义预检中文
AI 语义预检未得到可解析结果,需要 maintainer 人工审核。 影响范围
黄金链路
风险项
测试缺口
English
AI semantic review did not return a parseable result; maintainer review is required. Affected Areas
Golden Path
Findings
Test Gaps
|
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 changed
Add a 20 s timeout on the
http.getinImagePreviewCacheService._createPreviewFileand surface aTimeoutExceptionasImagePreviewUnavailable.Why
ImagePreviewCacheServiceis a process-wide singleton with a singleLock _previewLockheld around the whole download+compress. Thehttp.getused the default IO client with no timeout. A hung or blackholed remote image URL therefore held the lock indefinitely and blocked every other preview call — including local-file previews and the requests served overLocalAssetServerthat back the WebView.Adding a bounded timeout is the smallest safe change. The broader design question of sharding the lock per cache key (so unrelated in-flight fetches cannot block each other at all) is intentionally out of scope for this PR and worth its own discussion.
Closes #344
Type of change
Risk areas
Screenshots or recordings
No visual change.
Test plan
Not added. The service uses the top-level
http.get(not an injected client), so exercising the timeout branch requires an http-client injection refactor. That refactor is out of scope for this narrow fix.flutter testflutter analyzeContributor checklist
CONTRIBUTING.md.*.g.dartfiles manually.