From 16c8a62297e77e3d61ef588d1c4267168f7d432a Mon Sep 17 00:00:00 2001 From: James Kay Date: Wed, 18 Sep 2024 13:32:44 +0100 Subject: [PATCH] `js::module`: leave warning comment on the `Send` impl Until https://github.com/wasmerio/wasmer/issues/4158 is fixed, let's at least leave a signpost so future readers don't trip on it like I did :) --- lib/api/src/js/module.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/api/src/js/module.rs b/lib/api/src/js/module.rs index 61866abcf5f..adc61d6b08b 100644 --- a/lib/api/src/js/module.rs +++ b/lib/api/src/js/module.rs @@ -44,14 +44,10 @@ pub struct Module { raw_bytes: Option, } -// 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 {}