@@ -13,6 +13,7 @@ use std::future::Future;
13use std::path::{Path, PathBuf};
13use std::path::{Path, PathBuf};
14use std::str::FromStr;
14use std::str::FromStr;
15use std::sync::Arc;
15use std::sync::Arc;
16+use tokio::sync::mpsc::error::TryRecvError;
16use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
17use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
18use tokio::sync::Mutex;
19use tokio::sync::Mutex;
@@ -662,7 +663,16 @@ impl Document {
662 let save_req = if block {
663 let save_req = if block {
663 rx.recv().await
664 rx.recv().await
665− rx.try_recv().ok()
666+ let msg = rx.try_recv();
668+ if let Err(err) = msg {
670+ TryRecvError::Empty => return None,
671+ TryRecvError::Disconnected => None,
668 let save = match save_req {
678 let save = match save_req {