Skip to content

Commit 0b9d446

Browse files
committed
fix(agent): use is_peer_closed_error for RPC EOF detection
handle_connection treated any read_message error whose string contained "failed to read message header" as a clean EOF. That substring comes from anyhow::Context and prefixes *every* header-read failure — clean EOF, ConnectionReset, BrokenPipe, parse errors, you name it — so real errors were silently swallowed and never logged. Switch to the existing `vsock::is_peer_closed_error` helper, which inspects the underlying io::Error kind for BrokenPipe / ConnectionReset / ConnectionAborted / UnexpectedEof. Anything else now propagates and gets logged at error level by Agent::run. Pre-existing in master; surfaced by Copilot review on PR #276.
1 parent e1933b9 commit 0b9d446

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • guest/arcbox-agent/src/agent/linux

guest/arcbox-agent/src/agent/linux/rpc.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use super::kubernetes::{
2424
use super::runtime::{handle_ensure_runtime, handle_runtime_status};
2525
use super::sandbox::handle_sandbox_message;
2626
use super::system_info::handle_get_system_info;
27+
use super::vsock::is_peer_closed_error;
2728

2829
/// Result from handling a request.
2930
enum RequestResult {
@@ -43,8 +44,10 @@ where
4344
let (msg_type, trace_id, payload) = match read_message(&mut stream).await {
4445
Ok(msg) => msg,
4546
Err(e) => {
46-
// Check if it's an EOF (clean disconnect)
47-
if e.to_string().contains("failed to read message header") {
47+
// Treat peer-closed errors as a clean disconnect; surface
48+
// anything else (parse failure, unexpected I/O) to the
49+
// caller so it's logged.
50+
if is_peer_closed_error(&e) {
4851
tracing::debug!("Client disconnected");
4952
return Ok(());
5053
}

0 commit comments

Comments
 (0)