Skip to content

fix: catch unhandled errors when updating cache-hit metadata (#535) - #542

Open
mehmetbahadirgungor wants to merge 1 commit into
Baseflow:mainfrom
mehmetbahadirgungor:fix/unhandled-sqlite-cache-hit-metadata-535
Open

mehmetbahadirgungor wants to merge 1 commit into
Baseflow:mainfrom
mehmetbahadirgungor:fix/unhandled-sqlite-cache-hit-metadata-535

Conversation

@mehmetbahadirgungor

Copy link
Copy Markdown

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

Bug fix

⤵️ What is the current behavior?

When a cached file is retrieved, CacheStore fires an unawaited future to update cache-hit metadata without observing errors. If SQLite fails during this write (e.g. SQLite error 14 / unable to open database file), the error escapes as an unhandled asynchronous exception, even though a valid cached file is present on disk. In addition, errors during database retrieval or timer-scheduled cleanup could escape or leave pending futures uncompleted.

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

Errors from the cache-hit metadata update and scheduled cleanup are observed and logged via cacheLogger at warning level, preventing unhandled asynchronous exceptions while still returning the cached file. Pending retrieval futures also handle errors cleanly and clean up the future cache.

💥 Does this PR introduce a breaking change?

No

🐛 Recommendations for testing

Run flutter test test/cache_store_test.dart and flutter test. Unit tests verify that getFile returns FileInfo without unhandled errors when the database update fails on a cache hit, and that retrieval errors clean up pending cache.

📝 Links to relevant issues/docs

Fixes #535

🤔 Checklist before submitting

  • All projects build
  • Follows style guide lines (code style guide)
  • Relevant documentation was updated
  • Rebased onto current main
  • Version bumped and dated CHANGELOG entry added

Copilot AI balanced review requested due to automatic review settings October 23, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

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.

Unawaited cache-hit metadata update can surface iOS SQLite errors as unhandled

2 participants