Skip to content

web_sys::IdbObjectStore set_name has the wrong return type #4438

Open
@chairmank

Description

@chairmank

Describe the Bug

The IndexedDB specification (https://w3c.github.io/IndexedDB/#object-store-interface) and documentation on MDN (https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/name#exceptions) both state that the setter for the name property of IDBObjectStore can throw various exceptions.

Given the pattern of generated method signatures in web_sys, I expect the set_name method of web_sys::IdbObjectStore to return Result<(), JsValue>. Instead, both the Rust compiler and the generated documentation say that the return type of the set_name is ().

Here is the interface description in webidls/enabled/IDB.webidl:

[Exposed=(Window,Worker)]
interface IDBObjectStore {
  [SetterThrows] attribute DOMString name;
  [Throws] readonly attribute any keyPath;
  readonly attribute DOMStringList indexNames;
  [SameObject] readonly attribute IDBTransaction transaction;
  readonly attribute boolean autoIncrement;

Notice the [SetterThrows].

And here is the generated code in src/features/gen_IdbObjectStore.rs:

    # [wasm_bindgen (structural , method , setter , js_class = "IDBObjectStore" , js_name = name)]
    #[doc = "Setter for the `name` field of this object."]
    #[doc = ""]
    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/name)"]
    #[doc = ""]
    #[doc = "*This API requires the following crate features to be activated: `IdbObjectStore`*"]
    pub fn set_name(this: &IdbObjectStore, value: &str);

Is the #[wasm_bindgen(...)] attribute here missing catch?

Follow up question

There are many other JavaScript web APIs where a property setter can throw. Could there be similar problems elsewhere in web_sys?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions