{"record":{"id":"2fbc02654e0970ca","repo":"facebook/flow","slug":"failed-to-clear-spinner-line","errorCode":null,"errorMessage":"failed to clear spinner line","messagePattern":"failed to clear spinner line","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_cli/src/command_utils.rs","lineNumber":3004,"sourceCode":"        };\n        flow_parser::loc::with_full_source_serde(|| {\n            bincode::serde::encode_into_std_write(\n                &command,\n                stream,\n                bincode::config::legacy()\n                    .with_limit::<{ flow_commands_connect::command_connect_simple::MAX_FRAME_BYTES }>(),\n            )\n        })?;\n        Ok(())\n    }\n\n    fn eprintf_with_spinner(msg: &str) {\n        let stderr = std::io::stderr();\n        let mut stderr = stderr.lock();\n        if stderr.is_terminal() {\n            if flow_utils_tty::spinner_used() {\n                flow_utils_tty::print_clear_line(&mut stderr)\n                    .expect(\"failed to clear spinner line\");\n            }\n            write!(stderr, \"{}: {}\", msg, flow_utils_tty::spinner(false))\n                .expect(\"failed to write spinner status\");\n            stderr.flush().expect(\"failed to flush spinner status\");\n        } else {\n            writeln!(stderr, \"{}\", msg).expect(\"failed to write spinner status\");\n            stderr.flush().expect(\"failed to flush spinner status\");\n        }\n    }\n\n    // Waits for a response over the socket. If the connection dies, this will throw an exception\n    fn wait_for_response(\n        stream: &mut flow_common_socket::socket::SocketStream,\n        quiet: bool,\n        emoji: bool,\n        _root: &std::path::Path,\n    ) -> Result<server_prot::response::Response, ()> {\n        let use_emoji = flow_utils_tty::supports_emoji() && emoji;","sourceCodeStart":2986,"sourceCodeEnd":3022,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/rust_port/crates/flow_cli/src/command_utils.rs#L2986-L3022","documentation":"eprintf_with_spinner prints connect/status progress to stderr while the CLI talks to the flow server. When stderr is a terminal and the spinner animation has already drawn, flow_utils_tty::print_clear_line first emits the ANSI erase sequence \"\\r\\x1b[0K\" and flushes. Writing to a pts whose master side is gone returns EIO, so the .expect() panics while trying to redraw the spinner line.","triggerScenarios":"The CLI keeps running after its controlling terminal closed — ssh session dropped or terminal emulator quit while flow runs under nohup/disown with SIGHUP ignored — leaving stderr pointed at a dead pts; tmux/screen pane killed underneath the process; a pty-allocating wrapper (script -c) that exits early.","commonSituations":"Long checks left running over ssh that disconnects; CI wrappers allocating ptys that are torn down mid-run; terminal emulators crashing during long operations.","solutions":["For detached runs redirect stderr to a file so no write ever hits the dead pts: `flow ... 2>flow.log < /dev/null &`","Re-run the command in a live terminal / fresh session","Maintainer: make spinner cleanup best-effort — `let _ = print_clear_line(&mut stderr);` — since a failed UI redraw should never crash the CLI"],"exampleFix":"// before\nflow_utils_tty::print_clear_line(&mut stderr)\n    .expect(\"failed to clear spinner line\");\n\n// after\n// UI redraw is best-effort; never crash on a dead terminal\nlet _ = flow_utils_tty::print_clear_line(&mut stderr);","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// UI redraw is best-effort: a dead terminal must not crash the CLI\nlet _ = flow_utils_tty::print_clear_line(&mut stderr);","preventionTips":["For detached runs, always redirect stderr to a file: `flow ... 2>flow.log < /dev/null &`","Avoid pty-allocating wrappers (script -c) that exit before the wrapped command","Treat every spinner/ANSI write as non-critical — ignore its Result in code you control"],"tags":["rust","flow-cli","stderr","tty","eio","spinner","panic"],"backgroundTag":"stderr-write-failure","analyzedSha":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}