{"record":{"id":"df2d6b2e4b258ae0","repo":"facebook/flow","slug":"failed-to-flush-vim-emacs-errors","errorCode":null,"errorMessage":"failed to flush vim/emacs errors","messagePattern":"failed to flush vim/emacs errors","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_cli/src/status_command.rs","lineNumber":194,"sourceCode":"        } => {\n            let error_flags = &args.error_flags;\n            let from = flow_event_logger::get_from_i_am_a_clown();\n            if args.output_json {\n                print_json(&errors, &warnings, &suppressed_errors)\n            } else if matches!(from.as_deref(), Some(\"vim\") | Some(\"emacs\")) {\n                let strip_root = strip_root\n                    .as_deref()\n                    .map(|root| root.to_string_lossy().into_owned());\n                let stdout = std::io::stdout();\n                let mut out = stdout.lock();\n                flow_common_errors::error_utils::vim_emacs_output::print_errors(\n                    strip_root.as_deref(),\n                    &mut out,\n                    &errors,\n                    &warnings,\n                )\n                .expect(\"failed to write vim/emacs errors\");\n                out.flush().expect(\"failed to flush vim/emacs errors\");\n            } else {\n                let mut cli_errors = errors.clone();\n                for (error, _) in &suppressed_errors {\n                    cli_errors.add(error.clone());\n                }\n                let stdout = std::io::stdout();\n                let mut out = stdout.lock();\n                flow_common_errors::error_utils::cli_output::print_errors(\n                    &mut out,\n                    error_flags,\n                    &None,\n                    strip_root.as_deref(),\n                    &cli_errors,\n                    &warnings,\n                    lazy_msg.as_deref(),\n                )\n                .expect(\"failed to write cli errors\");\n                out.flush().expect(\"failed to flush cli errors\");","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/facebook/flow/blob/5c865861998a8ccb7dbc82b0c1f511e9ef60c3d9/rust_port/crates/flow_cli/src/status_command.rs#L176-L212","documentation":"Flush of the vim/emacs quickfix output from `flow status --from vim|emacs`. The quickfix lines are written to a locked stdout handle; if the report fits the stdio buffer the write succeeds in memory and this flush is where the vanished editor-side reader (BrokenPipe) or a full disk (ENOSPC) is detected, panicking via expect.","triggerScenarios":"The editor (or its plugin job) closes the pipe right after buffered writes complete — e.g. quitting vim while a status request is in flight — so flush returns EPIPE; redirected output hitting a full filesystem.","commonSituations":"Editor integrations cancelling in-flight status requests; scripted runs that close stdout early; disk-full CI environments.","solutions":["Plugins should wait for the flow process to exit before closing pipes.","Cancel requests by terminating the process rather than closing its stdout.","Redirect output to a file when debugging the integration.","Maintainer fix: BrokenPipe at flush → exit(0) as clean cancellation."],"exampleFix":"// before\nout.flush().expect(\"failed to flush vim/emacs errors\");\n\n// after\nif let Err(e) = out.flush() {\n    if e.kind() != std::io::ErrorKind::BrokenPipe {\n        panic!(\"failed to flush vim/emacs errors: {}\", e);\n    }\n    std::process::exit(0);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = out.flush() {\n    if e.kind() != std::io::ErrorKind::BrokenPipe {\n        panic!(\"failed to flush vim/emacs errors: {}\", e);\n    }\n    std::process::exit(0);\n}","preventionTips":["Treat BrokenPipe on --from vim/emacs output as normal cancellation, not an error.","Plugins: drain the quickfix stream and wait for process exit before cleanup.","Do not quit the editor while a status request is in flight when possible."],"tags":["stdout","broken-pipe","flush","vim","emacs","panic"],"backgroundTag":"broken-pipe","analyzedSha":"5c865861998a8ccb7dbc82b0c1f511e9ef60c3d9","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}