diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-11-18 17:28:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-18 17:28:14 -0500 |
commit | 763d492ed69c3a22310dd5c758995fbbbf3e06b8 (patch) | |
tree | da78f6e3ed7cc38924a73c2118b5824bcdb60e69 /cli/npm/cache.rs | |
parent | 6962808f4b6bfa18312820f710bc57c17980531d (diff) |
fix(npm): use an http client with connection pool (#16705)
Should make downloading npm packages faster and more reliable.
Diffstat (limited to 'cli/npm/cache.rs')
-rw-r--r-- | cli/npm/cache.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cli/npm/cache.rs b/cli/npm/cache.rs index 2ca597bd7..ce2208db7 100644 --- a/cli/npm/cache.rs +++ b/cli/npm/cache.rs @@ -10,11 +10,11 @@ use deno_core::anyhow::Context; use deno_core::error::custom_error; use deno_core::error::AnyError; use deno_core::url::Url; -use deno_runtime::deno_fetch::reqwest; use crate::deno_dir::DenoDir; use crate::file_fetcher::CacheSetting; use crate::fs_util; +use crate::http_util::HttpClient; use crate::progress_bar::ProgressBar; use super::registry::NpmPackageVersionDistInfo; @@ -315,6 +315,7 @@ impl ReadonlyNpmCache { pub struct NpmCache { readonly: ReadonlyNpmCache, cache_setting: CacheSetting, + http_client: HttpClient, progress_bar: ProgressBar, } @@ -322,11 +323,13 @@ impl NpmCache { pub fn from_deno_dir( dir: &DenoDir, cache_setting: CacheSetting, + http_client: HttpClient, progress_bar: ProgressBar, ) -> Self { Self { readonly: ReadonlyNpmCache::from_deno_dir(dir), cache_setting, + http_client, progress_bar, } } @@ -383,7 +386,7 @@ impl NpmCache { } let _guard = self.progress_bar.update(&dist.tarball); - let response = reqwest::get(&dist.tarball).await?; + let response = self.http_client.get(&dist.tarball).send().await?; if response.status() == 404 { bail!("Could not find npm package tarball at: {}", dist.tarball); |