QuotaExceededError thrown inconsistently across browsers when localStorage quota exceeded
0 reputation · 25 Feb 2021, 12:36 UTC
Cross-browser QuotaExceededError behavior
The HTML5 Web Storage specification defines QuotaExceededError as the failure condition when an origin exceeds its allocated localStorage quota, but leaves the exact quota size and eviction strategy implementation-defined. This creates an unresolved decision about how browsers signal quota exhaustion when setItem would exceed the limit.
Unresolved timing and exception consistency
It is unclear whether a setItem call that would exceed the quota throws immediately or after a best-effort write attempt, and whether the exception is consistently signaled as a DOMException with the name QuotaExceededError across user agents. Synchronous storage access blocks the main thread, so the timing of the throw affects page responsiveness under storage pressure.
Privacy modes and browser updates further vary the effective quota, making it difficult to predict the failure threshold without per-browser measurement.
- Does
setItemthrow synchronously before any write attempt when the payload would exceed the quota, or after a partial write? - Is the thrown exception always a
DOMExceptionwithname === "QuotaExceededError"in every conforming browser? - How do private-browsing contexts alter the quota limit and the error signaling compared to standard contexts?