Skip to content

on web-sys types not being Send and Sync #2753

Closed
@d-e-s-o

Description

@d-e-s-o

Representative of presumably (many?) more types, I'd like to understand why Window does not implement Send and Sync. I understand that it apparently embeds a js_sys::Object which contains a wasm_bindgen::JsValue which in turn has a PhantomData<*mut u8>, which causes everything using it to be !Send and !Sync by default. What I'd like to understand is whether lack of implementation of these traits is by design or an oversight.

I haven't found any discussion of this topic anywhere, so if you have any pointers kindly forward them.

Perhaps not implementing Send is not a big deal in a truly web world, but it has huge trickle down effects on downstream crates that cross this boundary (because web-sys, for example, is so low in the stack). E.g., I have a crate that provides functionality natively using native APIs or, when compiled for wasm32-unknown-unknown, using web APIs.
The native stuff is pretty much all Send, including futures created etc. But once the web backend is used, nothing is anymore. Now I have to sprinkle compile time conditions in dozens of places, which renders the code borderline unmaintainable and is just a humongous source of complexity. And it just doesn't get any better higher up the stack because these traits are so infectious.

Hence, can someone please

  • clarify whether this is an oversight or whether there has been discussion on the topic
  • if there are insurmountable issues with implementing these traits
  • clarify if we could document the lack of these trait implementations in the documentation

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