@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
3
3
use anyhow:: { bail, ensure, Context , Result } ;
4
4
use futures:: future:: try_join_all;
5
5
use reqwest:: Url ;
6
- use spin_common:: { paths:: parent_dir, ui:: quoted_path} ;
6
+ use spin_common:: { paths:: parent_dir, sloth , ui:: quoted_path} ;
7
7
use spin_locked_app:: {
8
8
locked:: {
9
9
self , ContentPath , ContentRef , LockedApp , LockedComponent , LockedComponentSource ,
@@ -94,6 +94,8 @@ impl LocalLoader {
94
94
} )
95
95
. collect :: < Result < Vec < _ > > > ( ) ?;
96
96
97
+ let sloth_guard = warn_if_component_load_slothful ( ) ;
98
+
97
99
// Load all components concurrently
98
100
let components = try_join_all ( components. into_iter ( ) . map ( |( id, c) | async move {
99
101
self . load_component ( & id, c)
@@ -102,6 +104,8 @@ impl LocalLoader {
102
104
} ) )
103
105
. await ?;
104
106
107
+ drop ( sloth_guard) ;
108
+
105
109
Ok ( LockedApp {
106
110
spin_lock_version : Default :: default ( ) ,
107
111
metadata,
@@ -516,3 +520,10 @@ fn file_url(path: impl AsRef<Path>) -> Result<String> {
516
520
. with_context ( || format ! ( "Couldn't resolve `{}`" , path. display( ) ) ) ?;
517
521
Ok ( Url :: from_file_path ( abs_path) . unwrap ( ) . to_string ( ) )
518
522
}
523
+
524
+ const SLOTH_WARNING_DELAY_MILLIS : u64 = 1250 ;
525
+
526
+ fn warn_if_component_load_slothful ( ) -> sloth:: SlothGuard {
527
+ let message = "Loading Wasm components is taking a few seconds..." ;
528
+ sloth:: warn_if_slothful ( SLOTH_WARNING_DELAY_MILLIS , format ! ( "{message}\n " ) )
529
+ }
0 commit comments