Skip to content

Expose DB Corrupt Error and Rethrow Errors - #82

Merged
Eliran Eretz-Kedosha (eliranek1) merged 4 commits into
masterfrom
user/eleretzk/rethrow-errors
Apr 15, 2026
Merged

Expose DB Corrupt Error and Rethrow Errors#82
Eliran Eretz-Kedosha (eliranek1) merged 4 commits into
masterfrom
user/eleretzk/rethrow-errors

Conversation

@eliranek1

Copy link
Copy Markdown
Contributor

Problem

Several error conditions in the IndexedDB provider were being silently swallowed, making production issues difficult to diagnose:

  1. dataLoss / dataLossMessage — Chromium's non-standard IDBVersionChangeEvent properties were completely ignored, meaning total data loss during upgrades went undetected
  2. onblocked events — No handler on IDBOpenDBRequest or deleteDatabase, so blocked opens/deletes were invisible
  3. onversionchange — Not handled, providing no visibility when another connection triggers a version upgrade
  4. Migration cursor errors — Silently caught and swallowed instead of re-thrown
  5. removeRange missing return — The remove() call result was discarded, so callers couldn't await completion
  6. getKeysForRange rejecting with void 0 — Actual error object was thrown away
  7. "Wiping db success" logged unconditionally — Logged even after a failed wipe
  8. [object Object] in error messages — DB open errors used ${err} instead of err.message/err.name
  9. Transaction errors missing error.name — Only message was logged, omitting the DOMException name (e.g., QuotaExceededError)

Changes

IndexedDbProvider.ts

  • Add onblocked handler on IDBOpenDBRequest — logs when open is blocked by existing connections
  • Read event.dataLoss / event.dataLossMessage in onupgradeneeded, log error on "total", pass through UpgradeMetadata
  • Add onversionchange handler — logs a warning (does not auto-close; existing connection has priority)
  • Re-throw cursor errors in migration instead of swallowing
  • Add onblocked handler on _deleteDatabaseInternal
  • Fix removeRange to return this.remove(keys)
  • Fix error message formatting to use err?.target?.error?.message / .name
  • Change "Wiping db success""Wiping db completed"
  • Include error.name in transaction error/abort detail strings

ObjectStoreProvider.ts

  • Add dataLoss?: "none" | "total" and dataLossMessage?: string to UpgradeMetadata

InMemoryProvider.ts

  • Fix getKeysForRange to reject with the actual error instead of void 0

extended-idb.d.ts

  • Augment IDBVersionChangeEvent with dataLoss and dataLossMessage (Chromium non-standard properties)

ObjectStoreProvider.spec.ts

  • Add 624 lines of tests covering all changes

Testing

All tests pass in ChromeHeadless via yarn test:ci.


Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Improves debuggability and correctness of IndexedDB/InMemory providers by surfacing previously swallowed failure modes (blocked opens/deletes, version changes, upgrade data loss, and cursor migration errors), and by returning/propagating real errors and promises to callers.

Changes:

  • Add telemetry hooks for onblocked, onversionchange, and Chromium dataLoss/dataLossMessage, and improve open/upgrade/transaction error formatting.
  • Stop swallowing migration cursor errors; ensure removeRange returns the removal promise.
  • Fix InMemory error propagation and add extensive test coverage for the new behaviors.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/types/extended-idb.d.ts Adds global typing for Chromium’s non-standard IDBVersionChangeEvent.dataLoss* fields.
src/ObjectStoreProvider.ts Extends UpgradeMetadata to include dataLoss and dataLossMessage.
src/IndexedDbProvider.ts Adds blocked/versionchange handlers, rethrows migration cursor errors, improves error messages, fixes removeRange return.
src/InMemoryProvider.ts Ensures getKeysForRange rejects with the actual error.
src/tests/ObjectStoreProvider.spec.ts Adds tests for new error/telemetry behavior and promise/error propagation fixes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tests/ObjectStoreProvider.spec.ts Outdated
Comment thread src/tests/ObjectStoreProvider.spec.ts
Comment thread src/tests/ObjectStoreProvider.spec.ts
Comment thread src/IndexedDbProvider.ts Outdated
vladar
vladar previously approved these changes Apr 15, 2026

@vladar vladar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but Copilot comment about flaky tests is a valid concern.

Comment thread src/InMemoryProvider.ts
@eliranek1
Eliran Eretz-Kedosha (eliranek1) merged commit 0300101 into master Apr 15, 2026
4 of 5 checks passed
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.

5 participants