From 148008c6954087c7be1382f6176a5d6bc9ef633f Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Tue, 8 Sep 2026 13:15:18 +0000 Subject: [PATCH] Refuse a wasm threads build where the Send and Sync impls assume one thread --- node-graph/libraries/core-types/src/registry.rs | 3 +++ node-graph/libraries/core-types/src/runtime.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/node-graph/libraries/core-types/src/registry.rs b/node-graph/libraries/core-types/src/registry.rs index d5b106996c..d8c7610245 100644 --- a/node-graph/libraries/core-types/src/registry.rs +++ b/node-graph/libraries/core-types/src/registry.rs @@ -217,6 +217,9 @@ unsafe impl Send for SourceHandle {} #[cfg(target_family = "wasm")] unsafe impl Sync for SourceHandle {} +#[cfg(all(target_family = "wasm", target_feature = "atomics"))] +compile_error!("SourceHandle's wasm Send/Sync rest on a single-threaded build; a +atomics target needs the stored node bounded instead"); + impl SourceHandle { pub fn new_record(node: std::sync::Arc) -> Self { Self::new_erased(node, record_source_type::()) diff --git a/node-graph/libraries/core-types/src/runtime.rs b/node-graph/libraries/core-types/src/runtime.rs index 77e0d65f92..28345ea062 100644 --- a/node-graph/libraries/core-types/src/runtime.rs +++ b/node-graph/libraries/core-types/src/runtime.rs @@ -30,6 +30,9 @@ unsafe impl Send for RuntimeHandle {} #[cfg(target_family = "wasm")] unsafe impl Sync for RuntimeHandle {} +#[cfg(all(target_family = "wasm", target_feature = "atomics"))] +compile_error!("RuntimeHandle's wasm Send/Sync rest on a single-threaded build; a +atomics target needs the payload bounded instead"); + impl std::fmt::Debug for RuntimeHandle { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("RuntimeHandle").finish_non_exhaustive() @@ -102,6 +105,9 @@ unsafe impl Send for GraphRuntime {} #[cfg(target_family = "wasm")] unsafe impl Sync for GraphRuntime {} +#[cfg(all(target_family = "wasm", target_feature = "atomics"))] +compile_error!("GraphRuntime's wasm Send/Sync are unbounded in S and rest on a single-threaded build; a +atomics target needs S bounded instead"); + impl GraphRuntime { pub fn new(spawner: S) -> Self { Self {