Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never get timed out from BrowserConfigBuilder #52

Closed
dwisiswant0 opened this issue Jul 1, 2021 · 1 comment · Fixed by #56
Closed

Never get timed out from BrowserConfigBuilder #52

dwisiswant0 opened this issue Jul 1, 2021 · 1 comment · Fixed by #56

Comments

@dwisiswant0
Copy link

Never met the end time of request_timeout from chromiumoxide::browser::BrowserConfigBuilder.

Environment

Chromiumoxide version: git+https://github.com/mattsse/chromiumoxide?branch=main#dd1003e68e9d9914c28cbb7d6022996833a465d9

Steps to Replicate

Code:

use {
    chromiumoxide::browser::{Browser, BrowserConfig},
    futures::StreamExt,
    std::time::{Duration, Instant}
};

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (browser, mut handler) = Browser::launch(
        BrowserConfig::builder()
            .request_timeout(Duration::from_secs(1))
            .build()?
        ).await?;

    let _handle = async_std::task::spawn(async move {
        loop {
            let _ = handler.next().await.unwrap();
        }
    });

    let start = Instant::now();

    let site = "https://photricity.com/flw/"; // this is endless loading website prank
    let page = browser.new_page(site).await?;
    let _html = page.wait_for_navigation().await?.content().await?;

    println!("Time elapsed: {:?}", start.elapsed());

    Ok(())
}

Proof of Concept

Expectations don't exceed the specified timeout (1sec), but quite the opposite.

Screenshot_2021-07-01_07-03-06

Additional context

The same thing happened to timeout field in chromiumoxide::cdp::js_protocol::runtime::EvaluateParams.

@mattsse
Copy link
Owner

mattsse commented Jul 3, 2021

Thanks for raising this.
This is indeed a bug.
while researching this I discovered #55 and with #56 this should be fixed.
The main reason your code did not fail was, because the default request timeout of 30s was used for the target init commands. After using the actual configured timeout it hang, because a timed out request wasn't handled. After #56 this fails now due to a timeout as expected.

Also wait_for_navigation is not needed in this case because new_page waits until it's fully loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants