Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

fix(webview): increase timeout for API response and improve error message

Tonhoc2cbc43f65ce
diff --git a/src-tauri/src/platforms/udemy/webview_api.rs b/src-tauri/src/platforms/udemy/webview_api.rs
index b7713156..c8261c35 100644
--- a/src-tauri/src/platforms/udemy/webview_api.rs
+++ b/src-tauri/src/platforms/udemy/webview_api.rs
@@ -79,7 +79,8 @@ pub async fn webview_get(
.map_err(|e| anyhow!("eval failed: {}", e))?;
let start = std::time::Instant::now();
- let timeout = Duration::from_secs(30);
+ let timeout = Duration::from_secs(90);
+ let mut poll_interval = 100u64;
loop {
if let Some(data) = result_store.lock().unwrap().take() {
if let Some(err_msg) = data.strip_prefix("{\"__fetch_error\":\"") {
@@ -89,8 +90,14 @@ pub async fn webview_get(
return Ok(data);
}
if start.elapsed() > timeout {
- return Err(anyhow!("Timeout waiting for API response"));
+ return Err(anyhow!(
+ "Timeout waiting for API response ({}s). The page may be blocked by Cloudflare or the server is slow.",
+ timeout.as_secs()
+ ));
+ }
+ tokio::time::sleep(Duration::from_millis(poll_interval)).await;
+ if poll_interval < 500 {
+ poll_interval = (poll_interval * 3 / 2).min(500);
}
- tokio::time::sleep(Duration::from_millis(100)).await;
}
}