diff --git a/crates/loader/src/local.rs b/crates/loader/src/local.rs index c9426e757..f614a7b90 100644 --- a/crates/loader/src/local.rs +++ b/crates/loader/src/local.rs @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf}; use anyhow::{bail, ensure, Context, Result}; use futures::future::try_join_all; use reqwest::Url; -use spin_common::{paths::parent_dir, ui::quoted_path}; +use spin_common::{paths::parent_dir, sloth, ui::quoted_path}; use spin_locked_app::{ locked::{ self, ContentPath, ContentRef, LockedApp, LockedComponent, LockedComponentSource, @@ -94,6 +94,8 @@ impl LocalLoader { }) .collect::>>()?; + let sloth_guard = warn_if_component_load_slothful(); + // Load all components concurrently let components = try_join_all(components.into_iter().map(|(id, c)| async move { self.load_component(&id, c) @@ -102,6 +104,8 @@ impl LocalLoader { })) .await?; + drop(sloth_guard); + Ok(LockedApp { spin_lock_version: Default::default(), metadata, @@ -516,3 +520,10 @@ fn file_url(path: impl AsRef) -> Result { .with_context(|| format!("Couldn't resolve `{}`", path.display()))?; Ok(Url::from_file_path(abs_path).unwrap().to_string()) } + +const SLOTH_WARNING_DELAY_MILLIS: u64 = 1250; + +fn warn_if_component_load_slothful() -> sloth::SlothGuard { + let message = "Loading Wasm components is taking a few seconds..."; + sloth::warn_if_slothful(SLOTH_WARNING_DELAY_MILLIS, format!("{message}\n")) +}