Skip to content

Commit aa2841c

Browse files
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: Cursor
1 parent 255b6e1 commit aa2841c

7 files changed

Lines changed: 803 additions & 196 deletions

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,29 @@ jobs:
6060
uses: Swatinem/rust-cache@v2
6161

6262
- name: Run clippy
63-
run: cargo clippy --target wasm32-unknown-unknown -- -D warnings
63+
run: cargo clippy --all-targets --target wasm32-unknown-unknown -- -D warnings
64+
65+
browser-test:
66+
name: Browser tests (${{ matrix.browser }})
67+
runs-on: ubuntu-latest
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
browser: [chrome, firefox]
72+
steps:
73+
- name: Checkout repository
74+
uses: actions/checkout@v4
75+
76+
- name: Install Rust toolchain
77+
uses: dtolnay/rust-toolchain@stable
78+
with:
79+
targets: wasm32-unknown-unknown
80+
81+
- name: Cache cargo dependencies
82+
uses: Swatinem/rust-cache@v2
83+
84+
- name: Install wasm-pack
85+
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
86+
87+
- name: Run headless browser tests
88+
run: wasm-pack test --headless --${{ matrix.browser }}

0 commit comments

Comments
 (0)