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

Inconsistent stdout flushing when using bacon run #185

Open
jasondyoungberg opened this issue Apr 15, 2024 · 0 comments
Open

Inconsistent stdout flushing when using bacon run #185

jasondyoungberg opened this issue Apr 15, 2024 · 0 comments

Comments

@jasondyoungberg
Copy link

When executing a Rust program using the bacon run command for the first time, the standard output is flushed on every newline. However, on subsequent runs, flushing appears to occur only upon program termination rather than as expected — every time the program itself issues a flush.

Expected Behavior

The expectation is for bacon run to flush the output consistently, in alignment with the behavior of my Rust program, which flushes after each output operation.

Current Behavior

  • Initial bacon run execution: Output is flushed on every newline.
  • Subsequent bacon run executions: Output is flushed only upon program termination.

Steps to Reproduce

  1. Use the following Rust code snippet:

    use std::{
        io::{stdout, Write},
        thread::sleep,
        time::Duration,
    };
    
    fn main() {
        for i in 0..10 {
            print!("\n{i}: ");
            for j in 0..10 {
                print!("{j} ");
                stdout().flush().unwrap();
                sleep(Duration::from_millis(100));
            }
        }
    }
  2. Run the program using cargo run to observe the expected behavior where every number is printed sequentially.

  3. Execute the program using bacon run to note the difference: only every line is printed during execution.

  4. On automatic execution upon save, observe that the output is displayed wholly at the end.

Environment

  • Rust version: 1.77.1
  • bacon version: 2.16.0
  • Operating System: Windows 11
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

No branches or pull requests

1 participant