From a7fe907a9216b7d799c0fd405840c61226037420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radim=20H=C3=B6fer?= Date: Fri, 9 Oct 2026 08:41:12 +0200 Subject: [PATCH] test(proxy): accept a reset as the closed connection after revocation `revoked_proxy_rejects_requests_without_closing_the_listener` expected a clean EOF when the proxy drops an existing connection after revocation. On Windows the drop sometimes arrives as WSAECONNRESET (10054) instead, depending on timing, which failed CI at random (seen on PR #65). The test now accepts EOF, ConnectionReset or ConnectionAborted, and still fails if the connection stays open or receives data. --- src/handlers/run/proxy.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/handlers/run/proxy.rs b/src/handlers/run/proxy.rs index 9090a43f..b2fea6bf 100644 --- a/src/handlers/run/proxy.rs +++ b/src/handlers/run/proxy.rs @@ -4622,14 +4622,23 @@ mod tests { r#"{"session_id":"ags_test","command":"agent","started_at":"","process_id":0,"process_started_at":"","revoked":true}"#, ) .unwrap(); + // The proxy drops the existing connection. Depending on timing the + // peer sees that as a clean EOF or, on Windows, as a reset (WSAECONNRESET + // 10054) — both mean the connection was closed. let mut closed = [0; 1]; - assert_eq!( - timeout(Duration::from_secs(2), existing.read(&mut closed)) - .await - .unwrap() - .unwrap(), - 0 - ); + match timeout(Duration::from_secs(2), existing.read(&mut closed)) + .await + .expect("existing connection was not closed after revocation") + { + Ok(count) => assert_eq!(count, 0, "existing connection received data"), + Err(error) => assert!( + matches!( + error.kind(), + std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted + ), + "unexpected error reading the closed connection: {error}" + ), + } let mut stream = tokio::net::TcpStream::connect(address).await.unwrap(); stream