From da6dc375d679d302e379214564913aee7ba6f722 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 28 Jun 2026 18:50:24 +0900 Subject: 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) --- crates/shirabe/src/repository/composer_repository.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/shirabe/src/repository/composer_repository.rs') diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index e3a5711..baf5768 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -32,6 +32,7 @@ use crate::util::HttpDownloader; use crate::util::Url; use crate::util::http::Response; use crate::util::r#loop::Loop; +use crate::util::sync_executor; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_metadata_minifier::MetadataMinifier; @@ -964,9 +965,8 @@ impl ComposerRepository { continue; } - let spec = tokio::runtime::Runtime::new() - .unwrap() - .block_on(self.start_cached_async_download(&name, Some(&name)))?; + let spec = + sync_executor::block_on(self.start_cached_async_download(&name, Some(&name)))?; // [$response] = $spec; let response = spec @@ -1726,9 +1726,8 @@ impl ComposerRepository { } let version_parser = self.version_parser.clone(); - let spec = tokio::runtime::Runtime::new() - .unwrap() - .block_on(self.start_cached_async_download(&name, Some(&real_name)))?; + let spec = + sync_executor::block_on(self.start_cached_async_download(&name, Some(&real_name)))?; // [$response, $packagesSource] = $spec; let spec_list = spec.as_list().cloned().unwrap_or_default(); -- cgit v1.3.1