Skip to content

Commit 9753eb9

Browse files
committed
Complain loudly if the main loop is blocked
1 parent aaa4861 commit 9753eb9

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

crates/ra_lsp_server/src/main_loop.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ mod handlers;
55
mod subscriptions;
66
pub(crate) mod pending_requests;
77

8-
use std::{error::Error, fmt, panic, path::PathBuf, sync::Arc, time::Instant};
8+
use std::{
9+
env,
10+
error::Error,
11+
fmt, panic,
12+
path::PathBuf,
13+
sync::Arc,
14+
time::{Duration, Instant},
15+
};
916

1017
use crossbeam_channel::{select, unbounded, RecvError, Sender};
1118
use lsp_server::{Connection, ErrorCode, Message, Notification, Request, RequestId, Response};
@@ -425,6 +432,19 @@ fn loop_turn(
425432
loop_state.subscriptions.subscriptions(),
426433
)
427434
}
435+
436+
let loop_duration = loop_start.elapsed();
437+
if loop_duration > Duration::from_millis(10) {
438+
log::error!("overly long loop turn: {:?}", loop_duration);
439+
if env::var("RA_PROFILE").is_ok() {
440+
show_message(
441+
req::MessageType::Error,
442+
format!("overly long loop turn: {:?}", loop_duration),
443+
&connection.sender,
444+
);
445+
}
446+
}
447+
428448
Ok(())
429449
}
430450

0 commit comments

Comments
 (0)