facebook/flow · warning

failed to flush spinner status

Error message

failed to flush spinner status

What it means

While showing progress for a long-running server command, the client writes spinner status to stderr and flushes it; if the flush fails, it panics with this message. This almost always means stderr is no longer writable (e.g. the terminal/pipe was closed).

Source

Thrown at rust_port/crates/flow_command_utils/src/lib.rs:2923

    fn print_status(msg: &str, enabled: bool, use_spinner: bool) {
        if !enabled {
            return;
        }

        let stderr = std::io::stderr();
        let mut stderr = stderr.lock();
        if use_spinner && stderr.is_terminal() {
            if flow_utils_tty::spinner_used() {
                flow_utils_tty::print_clear_line(&mut stderr)
                    .expect("failed to clear spinner line");
            }
            write!(stderr, "{}: {}", msg, flow_utils_tty::spinner(false))
                .expect("failed to write spinner status");
            stderr.flush().expect("failed to flush spinner status");
        } else {
            writeln!(stderr, "{}", msg).expect("failed to write spinner status");
            stderr.flush().expect("failed to flush spinner status");
        }
    }

    // Waits for a response over the socket. If the connection dies, this will throw an exception
    fn wait_for_response(
        stream: &mut flow_common_socket::socket::SocketStream,
        show_progress: bool,
        emoji: bool,
        _root: &std::path::Path,
    ) -> Result<server_prot::response::Response, ()> {
        let use_emoji = flow_utils_tty::supports_emoji() && emoji;
        stream.set_read_timeout(None).map_err(|_| ())?;
        loop {
            let response: Result<MonitorToClientMessage, _> =
                flow_parser::loc::with_full_source_serde(|| {
                    bincode::serde::decode_from_std_read(
                        &mut *stream,
                        bincode::config::legacy()

View on GitHub (pinned to 5c86586199)

Solutions

  1. Ensure stderr remains open for the duration of the flow command; avoid piping into consumers that exit early (e.g. `flow ... | head`).
  2. Disable progress/spinner output via non-TTY/stdout redirection or CI-appropriate flags so the spinner path is skipped.
  3. Check disk space / file permissions if stderr is redirected to a file.

Example fix

// before
flow check | head -n 5   # closes pipe early
// after
flow check > flow.log 2>&1; head -n 5 flow.log
Defensive patterns

Strategy: fallback

Validate before calling

test -w /dev/stderr || echo 'stderr not writable; disable spinner/progress output'

Try / catch

flow check > flow.log 2>&1 || { cat flow.log; exit 1; }

Prevention

When it happens

Trigger: stderr.flush() returns Err inside the progress printing helper — stderr redirected to a closed pipe or a full/unwritable file while a spinner is active.

Common situations: Running flow in CI where output pipes are closed early (`| head`), detached background jobs whose stderr fd was closed, or docker containers with detached TTYs.

Related errors


AI-assisted analysis of facebook/flow@5c86586199 (2026-09-08). Data as JSON: /api/errors/13850deaf8e01c3a. Report an issue: GitHub.