Skip to content

fix(web): report cached file read and decode failures on HttpGet - #1063

Merged
rickdijk merged 1 commit into
Baseflow:mainfrom
akashchamp:fix/web-httpget-decode-errors
Oct 29, 2026
Merged

rickdijk merged 1 commit into
Baseflow:mainfrom
akashchamp:fix/web-httpget-decode-errors

Conversation

@akashchamp

@akashchamp akashchamp commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Bug fix

⤵️ What is the current behavior?

With ImageRenderMethodForWeb.HttpGet, a failure to read or decode a cached file is an uncaught error. It never reaches the image stream, so the error widget and error listener are not called, the image is not evicted, the broken file stays in the cache and the streams are never closed. The placeholder stays forever.

🆕 What is the new behavior (if this is a feature change)?

A read or decode failure is added to the image stream, the broken cache entry is removed so the next attempt downloads again, the image is evicted once the entry is gone, and both controllers are closed. A stale cached file that fails to decode is only a failure if no fresh file follows; a failure after a frame was shown keeps that frame and does not touch the cache. A download error now closes the streams too. The streams are also closed when every decode finished before the download completed. Only the web loader removes the broken cache entry; the IO loader is unchanged.

💥 Does this PR introduce a breaking change?

No

🐛 Recommendations for testing

Added tests to cached_network_image_web (decode failure with and without a cache key, a failing removeFile, a stale file followed by a fresh one, both failing, a failure after a decoded frame, download errors, and the success path). They wait on the image stream's onDone instead of a fixed delay. In cached_network_image_web: flutter test and flutter test --platform chrome pass, flutter analyze is clean, and the files are formatted. The new failure tests fail without the fix.

📝 Links to relevant issues/docs

Fixes #1060

🤔 Checklist before submitting

  • All projects build
  • Follows style guide lines (code style guide)
  • Relevant documentation was updated
  • Rebased onto current main

@rickdijk rickdijk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, turning the uncaught read/decode error into a stream error is a clear improvement. A few things in the new close/cleanup logic, mostly around the case where getFileStream emits more than one FileInfo (stale cached copy followed by a fresh download), plus the download-error path.

A failure while reading or decoding a cached file was never delivered to the image stream. Report it, evict the image, remove the broken cache entry and close the streams. Also close the streams when every decode finished before the download completed.
@akashchamp
akashchamp force-pushed the fix/web-httpget-decode-errors branch from ac2a00f to b0f4ece Compare October 27, 2026 10:57
@rickdijk
rickdijk merged commit a2a555b into Baseflow:main Oct 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] HttpGet: read/decode failures are not reported to the image stream (placeholder forever, pending ImageCache entry)

2 participants