Zackriya-Solutions/meetily · error · anyhow::Error

Failed to flush {}: {}

Error message

Failed to flush {}: {}

What it means

After all chunks are written, the engine flushes the buffered async file writer with `writer.flush().await`. Any io::Error from the flush is mapped to `Failed to flush <filename>: <io error>` and aborts the download, since an unflushed file would be incomplete/corrupt on disk. Flush failures are typically deferred disk errors (ENOSPC, EIO) surfacing at flush time.

Source

Thrown at frontend/src-tauri/src/parakeet_engine/parakeet_engine.rs:1094

                    };
                    if let Some(callback) = &progress_callback {
                        callback(Self::in_flight_progress(
                            confirmed_bytes,
                            total_bytes,
                            speed_mbps,
                        ));
                    }
                    self.set_downloading_status(model_name, progress.percent).await;
                    last_percent = progress.percent;
                    last_report = Instant::now();
                    bytes_since_report = 0;
                }
            }

            writer
                .flush()
                .await
                .map_err(|error| anyhow!("Failed to flush {}: {}", artifact.filename, error))?;
            drop(writer);

            if active_download.cancellation.is_cancelled() {
                return Err(DownloadCancelled.into());
            }
            let stored_bytes = fs::metadata(&file_path)
                .await
                .map_err(|error| anyhow!("Failed to read {} after download: {}", artifact.filename, error))?
                .len();
            if stored_bytes != artifact.exact_bytes {
                return Err(anyhow!(
                    "{} stored {} bytes, expected exactly {} bytes",
                    artifact.filename,
                    stored_bytes,
                    artifact.exact_bytes
                ));
            }
        }

View on GitHub (pinned to a2cb62e827)

Solutions

  1. Free disk space — buffered data that silently fit the page cache often fails at flush when the disk is full.
  2. Avoid downloading to cloud-synced or network-mounted folders; keep the models dir on a local disk.
  3. Check disk health / system logs for I/O errors and run filesystem repair if EIO is reported.
  4. Disable/quarantine-check antivirus real-time scanning of the models directory and retry.
  5. Retry the download after resolving the storage issue; the partial file should be cleaned up and re-downloaded.
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure target volume is local and has headroom before download
let free = fs2::free_space(&models_dir)?;
if free < artifact.exact_bytes + 64 * 1024 * 1024 {
    return Err("insufficient disk space for model download".into());
}

Try / catch

match download_result {
    Err(e) if e.to_string().contains("Failed to flush") => {
        // Deferred I/O error: check space (ENOSPC), disk health (EIO),
        // or path on a synced/network volume; delete partial file and retry once
        cleanup_partial_file();
        eprintln!("Flush failed after download: {e}");
    }
    Err(e) => return Err(e),
    Ok(()) => {}
}

Prevention

When it happens

Trigger: `writer.flush().await` returns Err at the end of the artifact download loop — OS-level buffered-write failures reported when data is pushed to the filesystem.

Common situations: Disk filled up mid-download (writes buffered fine, fail on flush); network drive/synced folder (OneDrive, Dropbox, NFS) dropping connection; antivirus interfering at close; disk I/O errors.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of Zackriya-Solutions/meetily@a2cb62e827 (2026-09-12). Data as JSON: /api/errors/024437a906b78049. Report an issue: GitHub.