rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript
https://rustwasm.github.io/docs/wasm-bindgen/
Apache License 2.0
7.74k stars 1.07k forks source link

IDBDatabase webidl is incomplete #3959

Closed kegsay closed 2 months ago

kegsay commented 5 months ago

The IDBDatabase.webidl has:

    IDBTransaction transaction ((DOMString or sequence<DOMString>) storeNames,
                                optional IDBTransactionMode mode = "readonly");

However, this is missing the options field as detailed on MDN. The main (only?) option this presents is a critical one however: https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase/transaction#options as it provides the only way to actually make IndexedDB durable.

Is there any reason why this field is missing, and if not, can it be added? Otherwise it makes creating robust WASM code via Rust effectively impossible as you can't be sure your writes are tolerant to power failures / OS crashes.

Liamolucko commented 5 months ago

wasm-bindgen's WebIDL files were all copied from Firefox several years ago, and have been manually updated to add new APIs over the years. Firefox only seems to have implemented options recently, meaning that it wasn't in their WebIDL file back when we copied it and we still don't have it because nobody's added it since.

Feel free to make a PR adding it! There are instructions at https://rustwasm.github.io/wasm-bindgen/contributing/web-sys/supporting-more-web-apis.html. The WebIDL function definition should be the same as the one provided by the spec at https://w3c.github.io/IndexedDB/#idl-index.

In the long term, #2983 is the solution for how to stop things getting outdated like this in the first place.

kegsay commented 5 months ago

Firefox's support was only adding the durability property to the IDBTransaction. It's supported the option when creating the transaction much longer I thought.