Skip to content

Commit

Permalink
Remove unnecessary tokio::spawn
Browse files Browse the repository at this point in the history
- Unnecessary tokio spawn
- This is not compatible with web clients (WASM)
  • Loading branch information
viquezclaudio committed Apr 26, 2024
1 parent 0c1839f commit d96032f
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions network-interface/src/request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,24 +220,20 @@ pub fn request_handler<T: Send + Sync + Clone + 'static, Req: Handle<N, T>, N: N
let req_environment = req_environment.clone();
let network = Arc::clone(&network);

tokio::spawn(async move {
log::trace!("[{:?}] {:?} {:#?}", request_id, peer_id, msg);
log::trace!("[{:?}] {:?} {:#?}", request_id, peer_id, msg);

// Try to send the response, logging to debug if it fails
if let Err(err) = network
.respond::<Req>(request_id, msg.handle(peer_id, &req_environment))
.await
{
log::debug!(
"[{:?}] Failed to send {} response: {:?}",
request_id,
std::any::type_name::<Req>(),
err
);
};
})
.await
.expect("Request handler panicked")
// Try to send the response, logging to debug if it fails
if let Err(err) = network
.respond::<Req>(request_id, msg.handle(peer_id, &req_environment))
.await
{
log::debug!(
"[{:?}] Failed to send {} response: {:?}",
request_id,
std::any::type_name::<Req>(),
err
);
};
}
})
.await
Expand Down

0 comments on commit d96032f

Please sign in to comment.