docs(browser): add storage limits and persistence guidance - #84
Open
harish18092002 wants to merge 1 commit into
Open
docs(browser): add storage limits and persistence guidance#84harish18092002 wants to merge 1 commit into
harish18092002 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Closes #63.
docs/BROWSER.mdexplained how OPFS works — sync access handles, the Worker requirement, theflush()durability caveat — but a developer asking "how big can my database be in a browser, andwill it survive?" had no page to read. The only guidance was two sentences in a gotchas bullet,
which left four misconceptions unaddressed:
localStoragelimit, which belongs to a different storage systemwith its own separate quota.
persist()assumed to guarantee persistence, when it is a request whose boolean result has to bechecked.
Every claim in the new section is traceable to the implementation, existing project docs, or an
authoritative browser reference (MDN, WebKit).
How it works
Adds
## 7. Storage limits and persistencetodocs/BROWSER.md(7.1-7.7), renumbering "Which modeshould I use?" to section 8. It opens by separating the three ceilings people conflate — memory, WAL
growth, and the origin's quota — then covers each:
per-browser table labelled as browser policy rather than contract, including Firefox's 10 GiB
best-effort cap and WebKit's reduced quota for embedded web content.
estimate()— a Worker-safe example, plus the two caveats: the values are deliberatelyimprecise, and
usagecovers the whole origin, not just the.libredbfile.script-written storage, which for a database is a larger risk than quota.
write()toLibreDbError, and acatchexample narrowing on
code === "FAILED"thencause.name === "QuotaExceededError".records makes the file larger. Links Add WAL compaction to reclaim space and bound recovery time #12.
[P3][kernel] Stream recovery record-by-record to bound open() memory #64.
all five concerns.
Two points worth reviewer attention:
The
persist()example is on the main thread, not in the Worker. The issue asks for the call ithe Worker setup example, but
StorageManager.persist()is[Exposed=Window]and is not availablein workers — putting it in
db.worker.tswould document an API that does not exist there. It sitsin the main-thread half of the section 4.2 setup with the reason stated inline, and the
worker-exposed
persisted()/estimate()are shown alongside.Section 7.4 links rather than restates. It describes only what the browser contributes — a
QuotaExceededErrorarriving on the commit path — and defers toRELIABILITY.mdfor why the latchexists, so the durability contract keeps one home.
Two figures also differ from the issue body after checking the sources: Firefox best-effort quota i
the smaller of ~10% of disk or 10 GiB (the cap matters for a database), and Safari home-screen
web apps are not exempt from the seven-day rule — per WebKit they keep their own counter of days of
use, which using the app resets.
Also fixes a 404 link in section 2 that pointed at
libredb/libredbinstead oflibredb/libredb-database.src/core.ts,src/adapter/opfs.ts, and every test are untouched. The behaviour documented in 7.4already exists and is already covered — the latch refusing reads as well as writes is asserted in
src/core.hardening.test.ts.Checklist
bun run gatepasses locally (typecheck, format, lint, knip, build, size, test).Not applicable: documentation only, no source change. The gate still reports 348 passing test
and 100% line/function coverage.
bun run changeset).Intentionally omitted, per the issue's acceptance criteria: only
dist/is published, so docsnever reach the package.