Skip to content

Commit c0cad5b

Browse files
refactor: do not wait for update call
1 parent 561aab2 commit c0cad5b

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/ic-websocket-gateway/src/client_session.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use futures_util::{
99
use gateway_state::CanisterPrincipal;
1010
use ic_agent::{
1111
agent::{Envelope, EnvelopeContent},
12-
Agent, AgentError,
12+
Agent,
1313
};
1414
use serde::{Deserialize, Serialize};
1515
use serde_cbor::{from_slice, to_vec};
@@ -368,9 +368,7 @@ impl<S: AsyncRead + AsyncWrite + Unpin> ClientSession<S> {
368368
let canister_id = self.canister_id.expect("must be set");
369369

370370
// relay the envelope to the IC
371-
self.relay_envelope_to_canister(serialized_envelope, canister_id)
372-
.await
373-
.map_err(|e| IcWsError::IcWsProtocol(e.to_string()))?;
371+
self.relay_envelope_to_canister(serialized_envelope, canister_id);
374372

375373
// there is no need to relay the response back to the client as the response to a request to the /call enpoint is not certified by the canister
376374
// and therefore could be manufactured by the gateway
@@ -384,15 +382,20 @@ impl<S: AsyncRead + AsyncWrite + Unpin> ClientSession<S> {
384382
}
385383
}
386384

387-
async fn relay_envelope_to_canister(
388-
&self,
389-
serialized_envelope: Vec<u8>,
390-
canister_id: Principal,
391-
) -> Result<(), AgentError> {
392-
self.agent
393-
.update_signed(canister_id, serialized_envelope)
394-
.await?;
395-
Ok(())
385+
fn relay_envelope_to_canister(&self, serialized_envelope: Vec<u8>, canister_id: Principal) {
386+
let agent = self.agent.clone();
387+
tokio::spawn(
388+
async move {
389+
match agent.update_signed(canister_id, serialized_envelope).await {
390+
Ok(_) => (),
391+
Err(e) => {
392+
let err = IcWsError::IcWsProtocol(e.to_string());
393+
error!("Error relaying envelope to canister: {:?}", err)
394+
},
395+
}
396+
}
397+
.in_current_span(),
398+
);
396399
}
397400

398401
async fn handle_open_transition(

0 commit comments

Comments
 (0)