Skip to content

Commit 2520a37

Browse files
kinto0facebook-github-bot
authored andcommitted
stop timing out on failure
Summary: The language server thread now stays open forever when another thread panics. We should send an exit notification to stop it before panicing. other approaches: - D79298090 does not print the failed test - ? Reviewed By: grievejia Differential Revision: D79298267 fbshipit-source-id: 9306b68dced28779da18bd0cd8e8eadcf9c7a7e7
1 parent 9431077 commit 2520a37

File tree

1 file changed

+8
-1
lines changed
  • pyrefly/lib/test/lsp/lsp_interaction

1 file changed

+8
-1
lines changed

pyrefly/lib/test/lsp/lsp_interaction/util.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,20 @@ pub fn run_test_lsp(test_case: TestCase) {
9494
});
9595
// this thread sends messages to the language server (from test case)
9696
scope.spawn(move || {
97+
let exit_message= Message::Notification(Notification {method: Exit::METHOD.to_owned(), params: serde_json::json!(null)});
9798
for msg in
9899
get_initialize_messages(&test_case.workspace_folders, test_case.configuration, test_case.file_watch)
99100
.into_iter()
100101
.chain(test_case.messages_from_language_client)
101-
.chain(once(Message::Notification(Notification {method: Exit::METHOD.to_owned(), params: serde_json::json!(null)})))
102+
.chain(once(exit_message.clone()))
102103
{
104+
let stop_language_server = || {
105+
language_server_sender.send_timeout(exit_message.clone(), timeout).unwrap();
106+
};
103107
let send = || {
104108
eprintln!("client--->server {}", serde_json::to_string(&msg).unwrap());
105109
if let Err(err) = language_server_sender.send_timeout(msg.clone(), timeout) {
110+
// no need to stop_language_server, the channel is closed
106111
panic!("Failed to send message to language server: {:?}", err);
107112
}
108113
};
@@ -119,6 +124,7 @@ pub fn run_test_lsp(test_case: TestCase) {
119124
{
120125
// continue
121126
} else {
127+
stop_language_server();
122128
panic!("Did not receive response for request {:?}", id);
123129
}
124130
}
@@ -135,6 +141,7 @@ pub fn run_test_lsp(test_case: TestCase) {
135141
if request_id == *response_id {
136142
send();
137143
} else {
144+
stop_language_server();
138145
panic!(
139146
"language client received request {}, expecting to send response for {}",
140147
request_id, response_id

0 commit comments

Comments
 (0)