Lesson 0005 · ~14 minutes

Deal-breakers & integration risks

One skill: run a 60-second design-review scan — when IndexedDB is the wrong tool, and which production edges kill “just store it in IDB.”

Win for this lesson

You can reject a bad storage proposal quickly (wrong API, “durable forever,” no migration plan, multi-tab blindness) and green-light a good one with eyes open on quota and sync policy.

External sources still optional

You’ve been lesson-first — fine. This page is self-contained for the quiz. If you want one high-value skim later: web.dev Storage for the web (quota / eviction / spectrum) or MDN storage limits.

1. Wrong tool (reject before API details)

Requirement Usually not IDB Prefer
HTTP assets / app shell offline Object stores of Responses Cache API (+ SW)
Tiny flags, sync, main-thread only Full IDB ceremony Memory / careful Web Storage
File-shaped bytes, editor blobs Keyed records only OPFS (or Blob in IDB if record-shaped)
Auth tokens on every request IDB as cookie substitute HttpOnly cookies / proper auth design
Multi-device source of truth “IDB will sync itself” Server + explicit sync policy

Lesson 1 spectrum still applies: IDB wins for durable structured app data on this origin — not as a general kitchen sink.

2. “Durable forever” is not a promise

Browser storage is typically best-effort under pressure. Origins share a quota pool (IDB + Cache + other site data). When the device is low on space, browsers may evict site data — often least-recently-used origins first. Exact numbers and policies differ by browser and change over time; design for “may vanish,” not for a fixed 50 MB SLA.

Safari / iOS reality check

Treat long-lived client data on iOS Safari as especially hostile: storage can be capped or cleared under inactivity and privacy policies. Never pitch “offline forever on the user’s phone” without a server fallback and re-hydration path. (Details evolve — verify current WebKit / MDN notes before a hard product claim.)

3. Schema is a deploy

From lessons 2–4: version bumps, upgrade-only store/index creation, multi-tab versionchange / blocked. In a design review, “we’ll refactor the IDB shape next sprint” implies:

  1. Migration steps from every oldVersion still in the wild.
  2. Long-lived SPA tabs that never fully unload.
  3. Shared workers / multiple entrypoints opening the same DB.
  4. Rollback story if upgrade code throws mid-migration.

If the team cannot own that ceremony, keep the schema tiny and stable — or don’t put the feature in IDB yet.

4. Multi-tab and multi-writer

Multiple connections (tabs, workers) can read and write. Transactions serialize writers on overlapping stores, but product conflicts are yours: last write wins, optimistic versions, “open in two tabs and edit the same draft.” IDB does not give you CRDTs or presence.

5. Runtime footguns (integration)

Txn lifetime

await fetch mid-transaction → inactive/finished errors (lesson 3). Keep IDB work contiguous.

Main-thread abuse

IDB is async, but huge getAll + heavy decode on main still janks. Page big work; consider workers (you already know that track).

Wrapper ≠ magic

idb / Dexie improve ergonomics; they don’t remove quota, upgrade, or multi-tab product design.

6. Sync policy is product, not API

IndexedDB is a local store. Offline queues, conflict resolution, tombstones, and “server always wins” are features you design. Shipping IDB without answering who is the source of truth when the network returns? is a deal-breaker for multi-device products.

60-second review checklist

Wrong tool? · Survive eviction / clear-data? · Schema migration owned? · Multi-tab writers / upgrades? · Txn lifetime safe? · Sync policy explicit? · Main-thread cost bounded?

7. Practice

equal-length choices. Immediate feedback.

Scenario A

Product wants offline HTML/JS/CSS for the app shell. First store to reach for?

Scenario B

Design review claim: “Once written to IndexedDB it can never disappear until we delete it.” Your response?

Scenario C

Team wants to rename fields and add three indexes in next release. What must be in the plan?

Scenario D

“Two devices edit the same draft offline; both come online.” Who resolves the conflict?

Scenario E

Which integration pattern is a hard red flag?

8. What to remember

Ask your teacher Have a real feature design you want pressure-tested against this checklist? Paste it in chat.

Primary sources (optional, high value)

Still optional if you want to stay lesson-only. Best next reads when you choose to: