Skip to content

Websocket error log on .close() #287

@owickstrom

Description

@owickstrom

Hi! Thank you for working on this library, it's awesome.

When explicitly closing and awaiting the Browser, as recommended by the docs, I get the following error log from the handler module:

[2026-01-15T20:25:46.776Z ERROR chromiumoxide::handler] WS Connection error: Ws(Protocol(ResetWithoutClosingHandshake))

Here's a test case that exhibits this behavior:

#[tokio::test]
async fn test_browser_raw() {
    let env = env_logger::Env::default().default_filter_or("info");
    env_logger::Builder::from_env(env)
        .format_timestamp_millis()
        .format_target(true)
        .init();

    let url = "https://en.wikipedia.org";
    let user_data_directory = TempDir::new().unwrap();

    let (mut browser, mut handler) = chromiumoxide::Browser::launch(
        chromiumoxide::BrowserConfig::builder()
            .new_headless_mode()
            .user_data_dir(user_data_directory.path())
            .build()
            .unwrap(),
    )
    .await
    .unwrap();

    spawn(async move {
        loop {
            let _ = handler.next().await;
        }
    });

    let page = browser.new_page(url.to_string()).await.unwrap();
    let title = page.get_title().await.unwrap();
    assert_eq!(title, Some("Wikipedia, the free encyclopedia".to_string()));

    browser.close().await.unwrap();
    let exit = browser.wait().await.unwrap();
    assert_eq!(exit.unwrap().code(), Some(0));
}

If I comment out the last three lines and rely on Drop to do clean-up, I get this log instead:

[2026-01-15T20:26:33.605Z WARN  chromiumoxide::browser] Browser was not closed manually, it will be killed automatically in the background

The explicit call to .close() and .wait() seems to have worked before to silence the warning from .drop() (see #148). I could configure my logging to ignore logs from chromiumoxide::handler but it doesn't seem very wise, and this looks like a genuine issue?

Environment:

  • NixOS 25.11
  • Chromium 143.0.7499.40
  • chromiumoxide 0.8.0

Oh, also see #123. I can however reproduce this locally.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:1-repro-availableBug reproduction is availablekind:bugAn unexpected problem or behaviourtopic:processRelated to the spawn, management and kill of the chromium process

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions