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

Automatic chrome download does not seem to work? #286

Closed
FrankenApps opened this issue Jan 18, 2022 · 4 comments · Fixed by #293
Closed

Automatic chrome download does not seem to work? #286

FrankenApps opened this issue Jan 18, 2022 · 4 comments · Fixed by #293
Labels
bug Something isn't working

Comments

@FrankenApps
Copy link

I have a simple repro:

Cargo.toml

[package]
name = "basic_pdf"
version = "0.1.0"
edition = "2021"

[dependencies]
headless_chrome = { version = "0.9.0", features= ["fetch"] }

main.rs

use headless_chrome::{Browser, LaunchOptionsBuilder};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let launch_opts = LaunchOptionsBuilder::default()
        .headless(true)
        .build()?;
    let browser = Browser::new(launch_opts)?;

    println!("Wohoo we have a browser.");

    let tab = browser.wait_for_initial_tab()?;

    let wikidata = tab
        .navigate_to("https://www.wikipedia.org")?
        .wait_until_navigated()?
        .print_to_pdf(None)?;
    std::fs::write("wiki.pdf", &wikidata)?;
    println!("PDF successfully created from internet web page.");

    Ok(())
}

when I run this using cargo run, the application hangs for about 5 minutes and then finally exits with:

Error: Compat { error: NoAvailablePorts }

Version 0.9.0 on macos. I also tried:

headless_chrome = { git = "https://github.com/atroche/rust-headless-chrome", features= ["fetch"] }

but it does not build due to a missing dependency.

@mdrokz mdrokz added the bug Something isn't working label Feb 16, 2022
@mdrokz
Copy link
Collaborator

mdrokz commented Feb 16, 2022

I have a simple repro:

Cargo.toml

[package]
name = "basic_pdf"
version = "0.1.0"
edition = "2021"

[dependencies]
headless_chrome = { version = "0.9.0", features= ["fetch"] }

main.rs

use headless_chrome::{Browser, LaunchOptionsBuilder};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let launch_opts = LaunchOptionsBuilder::default()
        .headless(true)
        .build()?;
    let browser = Browser::new(launch_opts)?;

    println!("Wohoo we have a browser.");

    let tab = browser.wait_for_initial_tab()?;

    let wikidata = tab
        .navigate_to("https://www.wikipedia.org")?
        .wait_until_navigated()?
        .print_to_pdf(None)?;
    std::fs::write("wiki.pdf", &wikidata)?;
    println!("PDF successfully created from internet web page.");

    Ok(())
}

when I run this using cargo run, the application hangs for about 5 minutes and then finally exits with:

Error: Compat { error: NoAvailablePorts }

Version 0.9.0 on macos. I also tried:

headless_chrome = { git = "https://github.com/atroche/rust-headless-chrome", features= ["fetch"] }

but it does not build due to a missing dependency.

Can you try the github version again this PR #293 fixed the fetcher.

@mdrokz mdrokz linked a pull request Feb 16, 2022 that will close this issue
@FrankenApps
Copy link
Author

Yes, I think the fetcher might work now (not exactly sure how to test it), but whenever I try to use this version, I now get this panic which does not occur when I use a chromium version from a path:

Error: There are no available ports between 8000 and 9000 for debugging

@frederikhors
Copy link

I think we can close this.

@fcoury
Copy link
Contributor

fcoury commented Aug 1, 2023

Just for future reference, this is manifesting for me if I run as root without the --no-sandbox flag and I pushed a fix on this PR:

#406

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants