Skip to content

Commit c9ab2a9

Browse files
committed
fixup! cli: Close the websocket connection gracefully
1 parent 2944b50 commit c9ab2a9

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

crates/cli/src/subcommands/subscribe.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,11 @@ pub async fn exec(config: Config, args: &ArgMatches) -> Result<(), anyhow::Error
179179
task.await
180180
};
181181

182-
// Close the connection gracefully, unless it's a websocket error.
182+
// Close the connection gracefully, unless it's a websocket error,
183+
// in which case the connection is most likely already unusable.
183184
if !res.as_ref().is_err_and(|e| e.downcast_ref::<WsError>().is_some()) {
184-
ws.close(None).await?;
185+
// Ignore errors here, we're going to drop the connection anyways.
186+
let _ = ws.close(None).await;
185187
}
186188

187189
res
@@ -251,7 +253,7 @@ where
251253
}
252254
let Some(msg) = ws.try_next().await? else {
253255
eprintln!("disconnected by server");
254-
break Ok(());
256+
break Err(WsError::ConnectionClosed.into());
255257
};
256258

257259
let Some(msg) = parse_msg_json(&msg) else { continue };

0 commit comments

Comments
 (0)