From 175a71a00c228dc61a9652f34e81d02abf002f6e Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 18 Nov 2025 08:00:36 -0500 Subject: [PATCH] read error: fix error tight loop when tungstenite said we should keep polling until ConnectionClosed, they probably didn't mean ignore all other errors. --- constellation/src/consumer/jetstream.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/constellation/src/consumer/jetstream.rs b/constellation/src/consumer/jetstream.rs index ea56864..3808b48 100644 --- a/constellation/src/consumer/jetstream.rs +++ b/constellation/src/consumer/jetstream.rs @@ -226,13 +226,20 @@ pub fn consume_jetstream( println!("jetstream closed the websocket cleanly."); break; } - r => eprintln!("jetstream: close result after error: {r:?}"), + Err(_) => { + counter!("jetstream_read_fail", "url" => stream.clone(), "reason" => "dirty close").increment(1); + println!("jetstream failed to close the websocket cleanly."); + break; + } + Ok(r) => { + eprintln!("jetstream: close result after error: {r:?}"); + counter!("jetstream_read_fail", "url" => stream.clone(), "reason" => "read error") + .increment(1); + // if we didn't immediately get ConnectionClosed, we should keep polling read + // until we get it. + continue; + } } - counter!("jetstream_read_fail", "url" => stream.clone(), "reason" => "read error") - .increment(1); - // if we didn't immediately get ConnectionClosed, we should keep polling read - // until we get it. - continue; } }; -- 2.51.2