Skip to content

Commit

Permalink
fix(lsp): better handling of registry config errors (denoland#13418)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk committed Jan 19, 2022
1 parent 1cece36 commit 6cf0522
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use super::documents::to_lsp_range;
use super::documents::AssetOrDocument;
use super::documents::Documents;
use super::documents::LanguageId;
use super::logging::lsp_log;
use super::lsp_custom;
use super::parent_process_checker;
use super::performance::Performance;
Expand All @@ -63,7 +64,6 @@ use crate::deno_dir;
use crate::file_fetcher::get_source_from_data_url;
use crate::fs_util;
use crate::logger;
use crate::lsp::logging::lsp_log;
use crate::proc_state::import_map_from_text;
use crate::tools::fmt::format_file;
use crate::tools::fmt::format_parsed_source;
Expand Down
16 changes: 14 additions & 2 deletions cli/lsp/registries.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.

use super::logging::lsp_log;
use super::path_to_regex::parse;
use super::path_to_regex::string_to_regex;
use super::path_to_regex::Compiler;
Expand Down Expand Up @@ -544,8 +545,19 @@ impl ModuleRegistry {
// we can't use entry().or_insert_with() because we can't use async closures
if !self.origins.contains_key(&origin) {
let specifier = origin_url.join(CONFIG_PATH)?;
let configs = self.fetch_config(&specifier).await?;
self.origins.insert(origin, configs);
match self.fetch_config(&specifier).await {
Ok(configs) => {
self.origins.insert(origin, configs);
}
Err(err) => {
lsp_log!(
" Error fetching registry config for \"{}\": {}",
origin,
err.to_string()
);
self.origins.remove(&origin);
}
}
}

Ok(())
Expand Down

0 comments on commit 6cf0522

Please sign in to comment.