Open fl0rek opened 5 months ago
Another observation: &mut
borrows can also be problematic, as they can allow concurrent rw borrows from js, and these can only be checked at runtime.
Consider the example
struct Foo;
impl Foo {
async fn wait(&mut self) {
// do some computation
}
}
let foo = new Foo();
foo.wait();
foo.wait();
Since second wait
call will usually happen before the first promise is resolved, Foo
is still mutably borrowed there. This results in runtime error from bindgen:
Uncaught Error: recursive use of an object detected which would lead to unsafe aliasing in rust
This case is most easily tiggered with async fn
which borrows &mut
(as in example), but generally can happen anywhere where looser js rules violate Rust's single mutable borrow rule.
Currently,
WasmNode
expects to take ownership over the config when it's passed from JS. Nothing stops JS from still holding the config reference it has though, which causes an exception on access.JsValue
or is it relevant for to types?