aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-28 18:50:24 +0900
committernsfisis <nsfisis@gmail.com>2026-06-28 18:50:24 +0900
commitda6dc375d679d302e379214564913aee7ba6f722 (patch)
treeda57c376d065c239507d0d542f1f0bb3194977af /crates/shirabe/src/downloader
parent1b2473fd155b88c8aa90aaa844d183af617b6e8a (diff)
downloadphp-shirabe-da6dc375d679d302e379214564913aee7ba6f722.tar.gz
php-shirabe-da6dc375d679d302e379214564913aee7ba6f722.tar.zst
php-shirabe-da6dc375d679d302e379214564913aee7ba6f722.zip
fix(http): avoid nested tokio runtime panic in download path
The CurlDownloader owned a tokio runtime and block_on'd reqwest from its sync tick(), while the repository/installer/downloader sync bridges each created another Runtime and block_on'd async fns that reach that leaf. Driving one Runtime::block_on from within another panics with "Cannot start a runtime from within a runtime", hit by `require` when fetching p2 metadata. Switch CurlDownloader to a blocking reqwest client (its own internal thread, never nested) and replace the per-call Runtime::new().block_on bridges with a no-reactor sync_executor::block_on helper. No awaited future parks on a reactor once the only async I/O is blocking, so the helper can be nested freely. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/downloader')
-rw-r--r--crates/shirabe/src/downloader/file_downloader.rs27
1 files changed, 12 insertions, 15 deletions
diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs
index d3e1f6c..a6334fb 100644
--- a/crates/shirabe/src/downloader/file_downloader.rs
+++ b/crates/shirabe/src/downloader/file_downloader.rs
@@ -23,6 +23,7 @@ use crate::util::Platform;
use crate::util::ProcessExecutor;
use crate::util::Silencer;
use crate::util::Url as UrlUtil;
+use crate::util::sync_executor;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_php_shim::{
@@ -629,21 +630,17 @@ impl ChangeReportInterface for FileDownloader {
.remove_directory(format!("{}_compare", target_dir))?;
}
- tokio::runtime::Runtime::new()
- .unwrap()
- .block_on(self.download(
- package.clone(),
- &format!("{}_compare", target_dir),
- None,
- false,
- ))?;
- tokio::runtime::Runtime::new()
- .unwrap()
- .block_on(self.install(
- package.clone(),
- &format!("{}_compare", target_dir),
- false,
- ))?;
+ sync_executor::block_on(self.download(
+ package.clone(),
+ &format!("{}_compare", target_dir),
+ None,
+ false,
+ ))?;
+ sync_executor::block_on(self.install(
+ package.clone(),
+ &format!("{}_compare", target_dir),
+ false,
+ ))?;
let mut comparer = Comparer::new();
comparer.set_source(format!("{}_compare", target_dir));