From 37b69b8c4cc980de803bc24ae1d1a03e18b8cc4a Mon Sep 17 00:00:00 2001 From: cosineblast <55855728+cosineblast@users.noreply.github.com> Date: Sat, 22 Mar 2025 08:52:57 -0300 Subject: [PATCH] Make job mail-related commands not available in wasm WebAssembly doesn't have std::time::Instant, which is used by the job mailbox, so this commits restricts the mailbox commands so that they aren't available in WebAssembly targets. --- crates/nu-command/src/default_context.rs | 8 ++++++-- crates/nu-command/src/experimental/mod.rs | 13 ++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 64e0194de4..725221ed98 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -452,11 +452,15 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { JobList, JobKill, JobId, + Job, + }; + + #[cfg(not(target_family = "wasm"))] + bind_command! { JobSend, JobRecv, JobFlush, - Job, - }; + } #[cfg(all(unix, feature = "os"))] bind_command! { diff --git a/crates/nu-command/src/experimental/mod.rs b/crates/nu-command/src/experimental/mod.rs index ebd1dfe9c2..eb0b09ee2e 100644 --- a/crates/nu-command/src/experimental/mod.rs +++ b/crates/nu-command/src/experimental/mod.rs @@ -1,16 +1,20 @@ mod is_admin; mod job; -mod job_flush; mod job_id; mod job_kill; mod job_list; -mod job_recv; -mod job_send; mod job_spawn; #[cfg(all(unix, feature = "os"))] mod job_unfreeze; +#[cfg(not(target_family = "wasm"))] +mod job_flush; +#[cfg(not(target_family = "wasm"))] +mod job_recv; +#[cfg(not(target_family = "wasm"))] +mod job_send; + pub use is_admin::IsAdmin; pub use job::Job; pub use job_id::JobId; @@ -18,8 +22,11 @@ pub use job_kill::JobKill; pub use job_list::JobList; pub use job_spawn::JobSpawn; +#[cfg(not(target_family = "wasm"))] pub use job_flush::JobFlush; +#[cfg(not(target_family = "wasm"))] pub use job_recv::JobRecv; +#[cfg(not(target_family = "wasm"))] pub use job_send::JobSend; #[cfg(all(unix, feature = "os"))]