Skip to content

Commit ced09d9

Browse files
authored
duckdb build script http timeout (#3888)
With this we should be able to build vortex on slow connections, default timeout wasn't enough for me with my current connection (30secs?). Env vars are the same that are used to configure cargo itself Signed-off-by: Onur Satici <[email protected]>
1 parent 33c572b commit ced09d9

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

vortex-duckdb/build.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn download_duckdb_lib_archive() -> Result<PathBuf, Box<dyn std::error::Error>>
3333

3434
if !archive_path.exists() {
3535
println!("Downloading DuckDB libraries from {url}");
36-
let response = reqwest::blocking::get(&url)?;
36+
let response = http_client()?.get(&url).send()?;
3737
fs::write(&archive_path, &response.bytes()?)?;
3838
println!("Downloaded to {}", archive_path.display());
3939
} else {
@@ -81,7 +81,7 @@ fn download_duckdb_source_archive() -> Result<PathBuf, Box<dyn std::error::Error
8181

8282
if !archive_path.exists() {
8383
println!("Downloading DuckDB source code from {url}");
84-
let response = reqwest::blocking::get(&url)?;
84+
let response = http_client()?.get(&url).send()?;
8585
fs::write(&archive_path, &response.bytes()?)?;
8686
println!("Downloaded to {}", archive_path.display());
8787
} else {
@@ -117,6 +117,19 @@ fn extract_duckdb_source(archive_path: PathBuf) -> Result<PathBuf, Box<dyn std::
117117
Ok(duckdb_source_dir)
118118
}
119119

120+
fn http_client() -> Result<reqwest::blocking::Client, Box<dyn std::error::Error>> {
121+
let timeout_secs = env::var("CARGO_HTTP_TIMEOUT")
122+
.or_else(|_| env::var("HTTP_TIMEOUT"))
123+
.ok()
124+
.and_then(|s| s.parse().ok())
125+
.unwrap_or(90);
126+
127+
let client = reqwest::blocking::Client::builder()
128+
.timeout(std::time::Duration::from_secs(timeout_secs))
129+
.build()?;
130+
Ok(client)
131+
}
132+
120133
fn main() {
121134
let crate_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
122135
let duckdb_repo = crate_dir.join("duckdb");

0 commit comments

Comments
 (0)