diff options
| author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-05-16 00:09:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-16 07:09:35 +0000 |
| commit | 88983fb3eb5a085f7d358a7a98d5c738a21b5d27 (patch) | |
| tree | d4d83c5bd668edc25d30616fd4a3decc1cea3fb9 /cli/tools | |
| parent | bba553bea5938932518dc6382e464968ce8374b4 (diff) | |
fix(node): seperate worker module cache (#23634)
Construct a new module graph container for workers instead of sharing it
with the main worker.
Fixes #17248
Fixes #23461
---------
Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'cli/tools')
| -rw-r--r-- | cli/tools/bench/mod.rs | 33 | ||||
| -rw-r--r-- | cli/tools/installer.rs | 5 | ||||
| -rw-r--r-- | cli/tools/test/mod.rs | 27 |
3 files changed, 19 insertions, 46 deletions
diff --git a/cli/tools/bench/mod.rs b/cli/tools/bench/mod.rs index a6fb91776..dd94205cb 100644 --- a/cli/tools/bench/mod.rs +++ b/cli/tools/bench/mod.rs @@ -8,7 +8,6 @@ use crate::display::write_json_to_stdout; use crate::factory::CliFactory; use crate::factory::CliFactoryBuilder; use crate::graph_util::has_graph_root_local_dependent_changed; -use crate::module_loader::ModuleLoadPreparer; use crate::ops; use crate::tools::test::format_test_error; use crate::tools::test::TestFilter; @@ -145,24 +144,6 @@ fn create_reporter( Box::new(ConsoleReporter::new(show_output)) } -/// Type check a collection of module and document specifiers. -async fn check_specifiers( - cli_options: &CliOptions, - module_load_preparer: &ModuleLoadPreparer, - specifiers: Vec<ModuleSpecifier>, -) -> Result<(), AnyError> { - let lib = cli_options.ts_type_lib_window(); - module_load_preparer - .prepare_module_load( - specifiers, - false, - lib, - PermissionsContainer::allow_all(), - ) - .await?; - Ok(()) -} - /// Run a single specifier as an executable bench module. async fn bench_specifier( worker_factory: Arc<CliMainWorkerFactory>, @@ -445,12 +426,8 @@ pub async fn run_benchmarks( return Err(generic_error("No bench modules found")); } - check_specifiers( - cli_options, - factory.module_load_preparer().await?, - specifiers.clone(), - ) - .await?; + let main_graph_container = factory.main_module_graph_container().await?; + main_graph_container.check_specifiers(&specifiers).await?; if bench_options.no_run { return Ok(()); @@ -507,7 +484,6 @@ pub async fn run_benchmarks_with_watch( let graph_kind = cli_options.type_check_mode().as_graph_kind(); let module_graph_creator = factory.module_graph_creator().await?; - let module_load_preparer = factory.module_load_preparer().await?; let bench_modules = collect_specifiers( bench_options.files.clone(), @@ -559,7 +535,10 @@ pub async fn run_benchmarks_with_watch( .filter(|specifier| bench_modules_to_reload.contains(specifier)) .collect::<Vec<ModuleSpecifier>>(); - check_specifiers(cli_options, module_load_preparer, specifiers.clone()) + factory + .main_module_graph_container() + .await? + .check_specifiers(&specifiers) .await?; if bench_options.no_run { diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index 9ff17ccc3..b13dea6fd 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -284,8 +284,9 @@ pub async fn install_command( }; // ensure the module is cached - CliFactory::from_flags(flags.clone())? - .module_load_preparer() + let factory = CliFactory::from_flags(flags.clone())?; + factory + .main_module_graph_container() .await? .load_and_type_check_files(&[install_flags_global.module_url.clone()]) .await?; diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index 94d4caee0..2ff7203b7 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -10,8 +10,8 @@ use crate::factory::CliFactory; use crate::factory::CliFactoryBuilder; use crate::file_fetcher::File; use crate::file_fetcher::FileFetcher; +use crate::graph_container::MainModuleGraphContainer; use crate::graph_util::has_graph_root_local_dependent_changed; -use crate::module_loader::ModuleLoadPreparer; use crate::ops; use crate::util::file_watcher; use crate::util::fs::collect_specifiers; @@ -1305,12 +1305,10 @@ async fn fetch_inline_files( /// Type check a collection of module and document specifiers. pub async fn check_specifiers( - cli_options: &CliOptions, file_fetcher: &FileFetcher, - module_load_preparer: &ModuleLoadPreparer, + main_graph_container: &Arc<MainModuleGraphContainer>, specifiers: Vec<(ModuleSpecifier, TestMode)>, ) -> Result<(), AnyError> { - let lib = cli_options.ts_type_lib_window(); let inline_files = fetch_inline_files( file_fetcher, specifiers @@ -1346,13 +1344,8 @@ pub async fn check_specifiers( } } - module_load_preparer - .prepare_module_load( - module_specifiers, - false, - lib, - PermissionsContainer::allow_all(), - ) + main_graph_container + .check_specifiers(&module_specifiers) .await?; Ok(()) @@ -1701,7 +1694,6 @@ pub async fn run_tests( let cli_options = factory.cli_options(); let test_options = cli_options.resolve_test_options(test_flags)?; let file_fetcher = factory.file_fetcher()?; - let module_load_preparer = factory.module_load_preparer().await?; // Various test files should not share the same permissions in terms of // `PermissionsContainer` - otherwise granting/revoking permissions in one // file would have impact on other files, which is undesirable. @@ -1721,10 +1713,11 @@ pub async fn run_tests( return Err(generic_error("No test modules found")); } + let main_graph_container = factory.main_module_graph_container().await?; + check_specifiers( - cli_options, file_fetcher, - module_load_preparer, + main_graph_container, specifiers_with_mode.clone(), ) .await?; @@ -1863,7 +1856,6 @@ pub async fn run_tests_with_watch( let worker_factory = Arc::new(factory.create_cli_main_worker_factory().await?); - let module_load_preparer = factory.module_load_preparer().await?; let specifiers_with_mode = fetch_specifiers_with_test_mode( &cli_options, file_fetcher, @@ -1875,10 +1867,11 @@ pub async fn run_tests_with_watch( .filter(|(specifier, _)| test_modules_to_reload.contains(specifier)) .collect::<Vec<(ModuleSpecifier, TestMode)>>(); + let main_graph_container = + factory.main_module_graph_container().await?; check_specifiers( - &cli_options, file_fetcher, - module_load_preparer, + main_graph_container, specifiers_with_mode.clone(), ) .await?; |
