Commit aa2841c
committed
Bypass rexie, surface real DOM errors and harden commit batching
This release does three independent things, all motivated by the
user-visible "An IndexedDB error occured: idb error" failure reported
in surrealdb.js#571 / surrealist#1155 / indxdb#9 when calling
`db.use()` shortly after `db.connect('indxdb://...')`.
1. Wrap the underlying `idb` crate directly instead of going through
`rexie`. The `From<rexie::Error>` conversion only ever printed
"idb error" because `rexie::Error::IdbError` has no `{0}`
placeholder in its `Display` impl, so the inner DOMException name
and message were silently dropped before reaching the client. The
new `From<idb::Error>` impl pulls the `name`/`message` out of any
wrapped DOMException so callers see e.g. `InvalidStateError: A
request was placed against a transaction which is currently not
active` instead of the cryptic generic message.
2. Refactor `Transaction::commit()` to fire every buffered put and
delete through a single read-write IDB transaction, synchronously,
keeping only the most recently issued request handle. Only the last
request is awaited (the same pattern `idb::ObjectStore::put_all`
uses internally). Because no `.await` is interleaved with the
issuing loop, the IDB transaction's pending-request queue is never
empty during dispatch, so it cannot auto-commit prematurely. The
previous implementation awaited each `delete()` sequentially after
`put_all`, which the IDB spec does not guarantee will keep the
transaction active across the wake-up microtask boundary.
3. Add a `tests/web.rs` `wasm-bindgen-test` suite covering put/get
round-trips, mixed put+delete commits, multi-transaction sequences
(the shape of `db.use()`), savepoint rollback, read-your-own-writes
and conditional writes. Each test opens a freshly-named IDB
database so the suite is parallel-safe. CI runs the suite headless
under both Chrome and Firefox via `wasm-pack test`.
The public API is unchanged; the `rexie` dependency is dropped in
favour of `idb` directly.
Bumps the crate version to 0.13.0.
Made-with: Cursor1 parent 255b6e1 commit aa2841c
7 files changed
Lines changed: 803 additions & 196 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
0 commit comments