@@ -13,6 +13,7 @@ use std::future::Future;
1313use std::path::{Path, PathBuf};
1414use std::str::FromStr;
1515use std::sync::Arc;
16+use tokio::sync::mpsc::error::TryRecvError;
1617use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
1718
1819use tokio::sync::Mutex;
@@ -662,7 +663,16 @@ impl Document {
662663 let save_req = if block {
663664 rx.recv().await
664665 } else {
665− rx.try_recv().ok()
666+ let msg = rx.try_recv();
667+
668+ if let Err(err) = msg {
669+ match err {
670+ TryRecvError::Empty => return None,
671+ TryRecvError::Disconnected => None,
672+ }
673+ } else {
674+ msg.ok()
675+ }
666676 };
667677
668678 let save = match save_req {