diff --git a/daemon/src/connection.rs b/daemon/src/connection.rs index ad72627..e1c3f07 100644 --- a/daemon/src/connection.rs +++ b/daemon/src/connection.rs @@ -181,7 +181,8 @@ impl Context { if let Poll::Ready(maybe_message) = self.as_mut().socket.poll_next_unpin(cx) { let message = maybe_message.ok_or_eyre("Socket was closed while trying to recieve")?; if let Err(err) = self.as_mut().handle_receive(message) { - log::warn!("Got error while processing message: {}", err); + log::warn!("Got error while processing message: {:?}", err); + } } diff --git a/daemon/src/message.rs b/daemon/src/message.rs index f310b5d..637e550 100644 --- a/daemon/src/message.rs +++ b/daemon/src/message.rs @@ -28,8 +28,6 @@ impl CMProtoBufMessage { self.header.write_to_vec(&mut out)?; self.body.write_to_vec(&mut out)?; - log::trace!("Serialized message: {}", hex::encode(&out)); - Ok(out) } @@ -55,7 +53,10 @@ pub struct CMRawProtoBufMessage { impl CMRawProtoBufMessage { pub fn try_parse(binary: &[u8]) -> eyre::Result { if binary.len() < 8 { - eyre::bail!("Message too short for type"); + eyre::bail!( + "Message too short for type (need 8 bytes, was {} bytes)", + binary.len() + ); } let raw_action = u32::from_le_bytes(binary[0..4].try_into().unwrap()) & !0x8000_0000; let action = EMsg::from_i32(raw_action as i32) @@ -64,7 +65,11 @@ impl CMRawProtoBufMessage { let header_length = u32::from_le_bytes(binary[4..8].try_into().unwrap()); let header_end = 8 + header_length as usize; if binary.len() < header_end { - eyre::bail!("Message too short for header") + eyre::bail!( + "Message too short for header (need {}, was {})", + header_end, + binary.len() + ) } let header = CMsgProtoBufHeader::parse_from_bytes(&binary[8..header_end])?; @@ -113,10 +118,17 @@ impl CMRawProtoBufMessage { let full_length = u32::from_le_bytes(body[0..4].try_into().unwrap()); let message_end = 4 + full_length as usize; if body.len() < message_end { - eyre::bail!("sub-message too short") + eyre::bail!( + "sub-message too short (need {}, got {})", + message_end, + body.len() + ) } - items.push(Self::try_parse(&body[4..message_end])?); + match Self::try_parse(&body[4..message_end]) { + Ok(msg) => items.push(msg), + Err(err) => log::warn!("Failed to parse sub-message: {:?}", err), + } body = &body[message_end..]; } diff --git a/flake.nix b/flake.nix index 99b049d..acd54bf 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,7 @@ ]; RUST_SRC_PATH = "${rustPackages.rustPlatform.rustLibSrc}"; RUST_LOG = "debug,vapored=trace,vapore-client=trace"; + RUST_BACKTRACE = "1"; }; formatter = pkgs.nixfmt-rfc-style;