diff --git a/src/main.rs b/src/main.rs index 3ea00cc..f3e7b89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -180,7 +180,7 @@ fn main() -> Result<(), Box> { let launch_opts = LaunchOptionsBuilder::default() .headless(true) .sandbox(false) - .idle_browser_timeout(Duration::from_secs(600)) + .idle_browser_timeout(Duration::from_secs(cfg.timeout)) .path(browser_binary) .args(vec![ OsStr::new("--disable-pdf-tagging"), @@ -211,7 +211,7 @@ fn main() -> Result<(), Box> { // Create a new browser window. let browser = Browser::new(launch_opts)?; let tab = browser.new_tab()?; - tab.set_default_timeout(std::time::Duration::from_secs(300)); + tab.set_default_timeout(std::time::Duration::from_secs(cfg.timeout)); let page = tab.navigate_to(&url)?.wait_until_navigated()?; page.wait_for_element("#content-has-all-loaded-for-mdbook-pdf-generation")?; @@ -284,6 +284,7 @@ extern crate serde_derive; #[serde(default, rename_all = "kebab-case")] pub struct PrintOptions { pub trying_times: u64, + pub timeout: u64, pub browser_binary_path: String, pub static_site_url: String, pub landscape: bool, @@ -313,6 +314,7 @@ impl Default for PrintOptions { fn default() -> Self { PrintOptions { trying_times: 1u64, + timeout: 600u64, browser_binary_path: "".to_string(), static_site_url: "".to_string(), landscape: false, diff --git a/test_doc/book.toml b/test_doc/book.toml index 311a56f..8307b20 100644 --- a/test_doc/book.toml +++ b/test_doc/book.toml @@ -10,6 +10,8 @@ title = "An Example" [output.pdf] ## Set for auto-retrying if failed to generate PDF. # trying-times = 1 +## Set the timeout in seconds. +# timeout = 600 ## This backend only support latest Chromium based browsers, not Safari and Firefox currently. ## If needed, please specify the full path. ## If you specify the wrong binary, chances are that there will be a timeout error.