Skip to content

Buggy behaviour inside async context #707

@synalice

Description

@synalice
  1. Why isn't ^C printed to the terminal?
  2. Why is the spinner still drawn after calling finish_and_clear?
  3. (optional) What could cause the terminal to break the way it did inside the Nix devShell? I don't expect you to have any experience with Nix, so that's optional; just in case you have ay ideas. I've created an issue on NixOS forum about it — link.

I feel like there is a race condition somewhere inside this code, but I don't understand what exactly causes it.

Minimal Reproducible Example

Archive

indicatif-async-nix.zip

main.rs

#[tokio::main]
async fn main() {
    let pb = indicatif::ProgressBar::new_spinner().with_message("Beep-boop...");
    pb.enable_steady_tick(std::time::Duration::from_millis(80));

    tokio::signal::ctrl_c()
        .await
        .expect("should be able to set Ctrl-C handler");

    pb.finish_and_clear();

    tokio::time::sleep(std::time::Duration::from_secs(2)).await;
    println!("AHAHHAHA WHAT??????");
}

Screencast of the issue

indicatif-async-nix.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions