Skip to content

fix: don't drop the whole cache when the web storage quota is full - #25

Merged
nigrosimone merged 1 commit into
mainfrom
fix/storage-quota
Sep 2, 2026
Merged

nigrosimone merged 1 commit into
mainfrom
fix/storage-quota

Conversation

@nigrosimone

Copy link
Copy Markdown
Owner

When localStorage or sessionStorage refused a write because the quota was full, the store called clear(): one response too big for the quota threw away the entire cache, small entries included.

Worse, the error was recognized only by the name QuotaExceededError, which is what Chrome and Safari use. Firefox reports NS_ERROR_DOM_QUOTA_REACHED (code 1014) and some browsers only set the legacy code 22, so there the branch never ran: the write was silently lost and the storage stayed full, making every later write fail too.

Now the error is recognized by name and by code, and the default recovery evicts the oldest entries one at a time until the new one fits. onQuotaExceeded ('evict-oldest', 'clear', 'ignore') and maxQuotaRetry are options of withNgHttpCachingLocalStorage() and withNgHttpCachingSessionStorage().

Nine tests, including one per error flavour, all checked that they fail without the change.

@nigrosimone
nigrosimone merged commit 7c7eed0 into main Sep 2, 2026
3 checks passed
@nigrosimone
nigrosimone deleted the fix/storage-quota branch September 2, 2026 05:23
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.

1 participant