Skip to content

Commit

Permalink
Gracefully fail sending progress end
Browse files Browse the repository at this point in the history
Summary: It can happen during shutdown that there's some race condition and the main thread's receiving end is dropped before this code runs. Not crashing here makes the exit cleaner and error message more readable

Reviewed By: robertoaloi

Differential Revision: D58285304

fbshipit-source-id: e7cd7225de2d448d649ea12b172daa88411ef66e
  • Loading branch information
michalmuskala authored and facebook-github-bot committed Jun 7, 2024
1 parent ed3077e commit 25154e0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/elp/src/server/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

use crossbeam_channel::Receiver;
use crossbeam_channel::SendError;
use crossbeam_channel::Sender;
use lsp_types::NumberOrString;
use lsp_types::ProgressParams;
Expand Down Expand Up @@ -161,5 +162,7 @@ fn send_progress(sender: &Sender<ProgressTask>, token: NumberOrString, msg: Work
token,
value: ProgressParamsValue::WorkDone(msg),
};
sender.send(ProgressTask::Notify(params)).unwrap();
if let Err(SendError(err)) = sender.send(ProgressTask::Notify(params)) {
log::error!("Failed to send progress message: {:?}", err);
}
}

0 comments on commit 25154e0

Please sign in to comment.