File tree Expand file tree Collapse file tree 1 file changed +18
-15
lines changed
Expand file tree Collapse file tree 1 file changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -922,25 +922,28 @@ impl WasmChallengeExecutor {
922922 let key = platform_distributed_storage:: StorageKey :: new ( "wasm" , module_path) ;
923923
924924 // Spawn a new thread with its own runtime to avoid nesting runtimes
925- let ( tx , rx ) = std :: sync :: mpsc :: channel ( ) ;
926- std:: thread:: spawn ( move || {
927- let rt = tokio:: runtime:: Builder :: new_current_thread ( )
925+ // Use join() to ensure thread completes before returning
926+ let handle = std:: thread:: spawn ( move || {
927+ let rt = match tokio:: runtime:: Builder :: new_current_thread ( )
928928 . enable_all ( )
929- . build ( ) ;
930- let result = match rt {
931- Ok ( rt) => rt. block_on ( async {
932- storage
933- . get ( & key, platform_distributed_storage:: GetOptions :: default ( ) )
934- . await
935- . ok ( )
936- . flatten ( )
937- } ) ,
938- Err ( _) => None ,
929+ . build ( )
930+ {
931+ Ok ( rt) => rt,
932+ Err ( _) => return None ,
939933 } ;
940- let _ = tx. send ( result) ;
934+ let result = rt. block_on ( async {
935+ storage
936+ . get ( & key, platform_distributed_storage:: GetOptions :: default ( ) )
937+ . await
938+ . ok ( )
939+ . flatten ( )
940+ } ) ;
941+ // Explicitly shutdown runtime before thread exit
942+ drop ( rt) ;
943+ result
941944 } ) ;
942945
943- match rx . recv ( ) {
946+ match handle . join ( ) {
944947 Ok ( Some ( stored) ) => {
945948 info ! (
946949 module = module_path,
You can’t perform that action at this time.
0 commit comments