Skip to content

fix(image cache): add HTTP timeout to network image preview download - #343

Merged
sparkleMing merged 1 commit into
memex-lab:mainfrom
thejesh23:fix/image-preview-http-timeout
Jul 24, 2026
Merged

sparkleMing merged 1 commit into
memex-lab:mainfrom
thejesh23:fix/image-preview-http-timeout

Conversation

@thejesh23

@thejesh23 thejesh23 commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Add a 20 s timeout on the http.get in ImagePreviewCacheService._createPreviewFile and surface a TimeoutException as ImagePreviewUnavailable.

Why

ImagePreviewCacheService is a process-wide singleton with a single Lock _previewLock held around the whole download+compress. The http.get used 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 over LocalAssetServer that 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

  • Bug fix

Risk areas

  • None of the above

Screenshots or recordings

No visual change.

Test plan

  • Added/updated unit tests for changed non-UI behavior, or explained why not:
    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.
  • Exact test files: n/a
  • flutter test
  • flutter analyze
  • Manual iOS check
  • Manual Android check
  • Not run; reason: no Flutter toolchain on the audit machine. Please run the CI checks before merging.

Contributor checklist

  • I read CONTRIBUTING.md.
  • I kept this PR focused on one change.
  • I did not edit generated *.g.dart files manually.
  • I did not add telemetry, hidden network calls, secrets, or signing keys.
  • I updated docs or localization when needed. (No docs or strings touched.)

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.
@github-actions

Copy link
Copy Markdown

PR AI Review / PR AI 语义预检

中文

  • 风险等级:高风险
  • 需要人工审核:是
  • 黄金链路影响:可能
  • 置信度:high
  • Workflow run:29766627425

AI 语义预检未得到可解析结果,需要 maintainer 人工审核。

影响范围

  • unknown

黄金链路

  • none
  • 说明:Claude Code Action 未产出结构化 JSON,AI 语义预检结果不可用。

风险项

  • high AI review 结果不可用。证据:Claude Code Action structured_output was empty or invalid.。
    建议:检查 Claude Action 日志和模型网关配置后重新运行 workflow。

测试缺口

  • 未发现新的测试缺口。

English

  • Risk level: HIGH
  • Human review required: YES
  • Golden path impact: POSSIBLE
  • Confidence: high
  • Workflow run: 29766627425

AI semantic review did not return a parseable result; maintainer review is required.

Affected Areas

  • unknown

Golden Path

  • none
  • Rationale: Claude Code Action did not produce structured JSON, so the AI review result is unavailable.

Findings

  • high AI review result unavailable. Evidence: Claude Code Action structured_output was empty or invalid..
    Recommendation: Check Claude Action logs and model gateway configuration, then rerun the workflow.

Test Gaps

  • No new test gap was reported.

AI review is advisory. Maintainers should verify the result before merging.

@github-actions github-actions Bot added ai: high risk AI review classified the PR as high risk golden path impact AI review found possible impact to a core user flow needs human review AI review or policy signals require maintainer review labels Jul 20, 2026
@sparkleMing
sparkleMing merged commit d8f5859 into memex-lab:main Jul 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai: high risk AI review classified the PR as high risk golden path impact AI review found possible impact to a core user flow needs human review AI review or policy signals require maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image preview cache: hung network image URL blocks all previews (no HTTP timeout)

2 participants