The following code does not work as expected on Firefox:
use rexie::{ObjectStore, Rexie, TransactionMode};
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub async fn testcase() -> Result<(), JsValue> {
let db = Rexie::builder("testcase")
.add_object_store(
ObjectStore::new("store")
.key_path("id")
.auto_increment(true),
)
.build()
.await?;
let tx = db.transaction(&["store"], TransactionMode::ReadWrite)?;
let store = tx.store("store")?;
let value = serde_wasm_bindgen::to_value(&serde_json::json!({ "content": "test" }))?;
store.add(&value, None).await?;
Ok(())
}
Instead, it gets stuck on the await in the line where the item is added, and by checking devtools, one sees that the item is not inserted into the database.
For reference, the code above works in Chromium, and the following functionally equivalent JS code works on both Firefox and Chromium:
const openRequest = indexedDB.open("testcase", 1);
openRequest.onupgradeneeded = e => {
const db = e.target.result;
const objectStore = db.createObjectStore("store", { keyPath: "id", autoIncrement: true });
};
openRequest.onsuccess = e => {
console.log(e);
const db = e.target.result;
const tx = db.transaction("store", "readwrite");
const store = tx.objectStore("store");
store.put({ content: "test" });
};
So I suspect this is a Rexie bug exposed by browser differences (although it might also be a browser bug exposed by Rexie).
The following code does not work as expected on Firefox:
Instead, it gets stuck on the await in the line where the item is added, and by checking devtools, one sees that the item is not inserted into the database.
For reference, the code above works in Chromium, and the following functionally equivalent JS code works on both Firefox and Chromium:
So I suspect this is a Rexie bug exposed by browser differences (although it might also be a browser bug exposed by Rexie).