Skip to content

Commit 2a19459

Browse files
Avoid failing on incorrect settings response
1 parent fbef012 commit 2a19459

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,23 @@ fn loop_turn(
414414
log::error!("unexpected response: {:?}", resp)
415415
}
416416

417-
if Some(resp.id) == loop_state.configuration_request_id {
417+
if Some(&resp.id) == loop_state.configuration_request_id.as_ref() {
418418
loop_state.configuration_request_id = None;
419+
log::debug!("config update response: '{:?}", resp);
419420
let Response { error, result, .. } = resp;
420-
match (error, result) {
421+
422+
match (
423+
error,
424+
result.map(|result| serde_json::from_value::<Vec<ServerConfig>>(result)),
425+
) {
421426
(Some(err), _) => {
422427
log::error!("failed to fetch the server settings: {:?}", err)
423428
}
424-
(None, Some(result)) => {
425-
let new_config = serde_json::from_value::<Vec<ServerConfig>>(result)?
429+
(None, Some(Ok(new_config))) => {
430+
let new_config = new_config
426431
.first()
427432
.expect(
428-
"The client is expected to always send a non-empty config data",
433+
"the client is expected to always send a non-empty config data",
429434
)
430435
.to_owned();
431436
world_state.update_configuration(
@@ -434,6 +439,9 @@ fn loop_turn(
434439
get_feature_flags(&new_config, connection),
435440
);
436441
}
442+
(None, Some(Err(e))) => {
443+
log::error!("failed to parse client config response: {}", e)
444+
}
437445
(None, None) => {
438446
log::error!("received empty server settings response from the client")
439447
}

0 commit comments

Comments
 (0)