Repository navigation
fix: catch unhandled errors when updating cache-hit metadata (#535) - #542
Conversation
There was a problem hiding this comment.
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.
rickdijk
left a comment
There was a problem hiding this comment.
8 inline comments below. The first three are the most important: unhandled errors can still escape through _cleanupCache, emptyCache/removeCachedFile can now leave orphaned DB rows, and a failed DB read now blocks the network download fallback.
There was a problem hiding this comment.
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.
|
Thanks for the thorough and insightful review @rickdijk! All 8 points have been addressed in the latest commit:
|
rickdijk
left a comment
There was a problem hiding this comment.
Thanks @mehmetbahadirgungor, all 8 points from the first round are addressed. Format, analyze and the full test suite pass locally on this commit. I left two small comments and a nit below. None of them block merging: with the CHANGELOG/description update in, I'm happy to approve, and the orphaned-file case can be a follow-up.
There was a problem hiding this comment.
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.
|
Thanks again @rickdijk! All 3 follow-up points are in:
|
rickdijk
left a comment
There was a problem hiding this comment.
Thanks @mehmetbahadirgungor, the three follow-ups look good. I've checked that the new tests fail on main and pass here, and format, analyze and the full suite pass locally. There's one last small thing below, introduced by the cleanup in the latest commit. Once that's in I'll approve, and I'll approve the CI workflow run too.
|
Thanks @rickdijk! That's a great catch. Handled in the latest commit: In
Added a unit test in |
There was a problem hiding this comment.
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.
rickdijk
left a comment
There was a problem hiding this comment.
Thanks @mehmetbahadirgungor, this looks good. The memory-cache fix is correct, and the new test fails without it. Format, analyze and all 116 tests pass locally on this commit. Approving, and I'll merge once CI is green.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Bug fix
When a cached file is retrieved,
CacheStorefires 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)?
cacheLoggerat warning level with stack traces, preventing unhandled asynchronous exceptions while returning the cached file.null), allowing network download fallbacks to proceed cleanly when the database is unavailable.WebHelper, the orphaned file is removed from disk.💥 Does this PR introduce a breaking change?
No
🐛 Recommendations for testing
Run
flutter test test/cache_store_test.dart,flutter test test/web_helper_test.dart, andflutter test. Unit tests verify that:getFilereturnsFileInfowithout unhandled errors when the database update fails on a cache hit.putFilefails.📝 Links to relevant issues/docs
Fixes #535
🤔 Checklist before submitting