Skip to content

Commit

Permalink
Merge pull request #5098 from Twey/patch-1
Browse files Browse the repository at this point in the history
`js::module`: leave warning comment on the `Send` impl
  • Loading branch information
syrusakbary authored Oct 3, 2024
2 parents 5bc6087 + 16c8a62 commit 3d638e4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/api/src/js/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ pub struct Module {
raw_bytes: Option<Bytes>,
}

// Module implements `structuredClone` in js, so it's safe it to make it Send.
// https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
// ```js
// const module = new WebAssembly.Module(new Uint8Array([
// 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00
// ]));
// structuredClone(module)
// ```
// XXX
// Do not rely on `Module` being `Send`: it will panic at runtime
// if accessed from multiple threads thanks to [`JsHandle`].
// See https://github.com/wasmerio/wasmer/issues/4158 for details.
unsafe impl Send for Module {}
unsafe impl Sync for Module {}

Expand Down

0 comments on commit 3d638e4

Please sign in to comment.