From a05db980181e2d4eed2fe33928774666ec0eb950 Mon Sep 17 00:00:00 2001 From: anaslimem Date: Sat, 28 Mar 2026 08:50:25 +0100 Subject: [PATCH] add warning logs for silent failures in RPC message handling --- src/agent-client-protocol/src/rpc.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/agent-client-protocol/src/rpc.rs b/src/agent-client-protocol/src/rpc.rs index d4694b7..07280a9 100644 --- a/src/agent-client-protocol/src/rpc.rs +++ b/src/agent-client-protocol/src/rpc.rs @@ -174,7 +174,9 @@ where serde_json::to_writer(&mut outgoing_line, &JsonRpcMessage::wrap(&message)).map_err(Error::into_internal_error)?; log::trace!("send: {}", String::from_utf8_lossy(&outgoing_line)); outgoing_line.push(b'\n'); - outgoing_bytes.write_all(&outgoing_line).await.ok(); + if let Err(e) = outgoing_bytes.write_all(&outgoing_line).await { + log::warn!("failed to send message to peer: {e}"); + } broadcast.outgoing(&message); } else { break; @@ -194,7 +196,9 @@ where match Local::decode_request(&method, message.params) { Ok(request) => { broadcast.incoming_request(id.clone(), &*method, &request); - incoming_tx.unbounded_send(IncomingMessage::Request { id, request }).ok(); + if let Err(e) = incoming_tx.unbounded_send(IncomingMessage::Request { id, request }) { + log::warn!("failed to send request to handler, channel full: {e:?}"); + } } Err(error) => { outgoing_line.clear(); @@ -206,7 +210,9 @@ where serde_json::to_writer(&mut outgoing_line, &JsonRpcMessage::wrap(&error_response))?; log::trace!("send: {}", String::from_utf8_lossy(&outgoing_line)); outgoing_line.push(b'\n'); - outgoing_bytes.write_all(&outgoing_line).await.ok(); + if let Err(e) = outgoing_bytes.write_all(&outgoing_line).await { + log::warn!("failed to send error response to peer: {e}"); + } broadcast.outgoing(&error_response); } } @@ -235,7 +241,9 @@ where match Local::decode_notification(&method, message.params) { Ok(notification) => { broadcast.incoming_notification(&*method, ¬ification); - incoming_tx.unbounded_send(IncomingMessage::Notification { notification }).ok(); + if let Err(e) = incoming_tx.unbounded_send(IncomingMessage::Notification { notification }) { + log::warn!("failed to send notification to handler, channel full: {e:?}"); + } } Err(err) => { log::error!("failed to decode {:?}: {err}", message.params);