tonhowtf/omniget · warning

ainda nao ha nada no buffer

Error message

ainda nao ha nada no buffer

What it means

save_replay collects existing segment files from the ring directory, dropping the last segment that is still being written. If, after that, no segments remain (segs.is_empty()), there is nothing to concatenate, so 'ainda nao ha nada no buffer' (nothing in the buffer yet) is thrown. Replay needs at least one completed 5-second segment.

Solutions

  1. Wait until at least one full segment (~5s) plus rollover has completed before calling save_replay.
  2. Retry after a short delay if the action is user-triggered too early.
  3. Increase replay_seconds so the requested window covers more segments.

Example fix

// before
let out = save_replay().await?;
// after
if seconds_since_recording_start() < 10 {
    tokio::time::sleep(std::time::Duration::from_secs(5)).await;
}
let out = save_replay().await?;
Defensive patterns

Strategy: retry

Validate before calling

// Rust
async fn replay_ready(min_age: Duration) -> bool {
    elapsed_since_recording_start() >= min_age
}

Type guard

null

Try / catch

let mut attempt = 0;
let out = loop {
    match save_replay().await {
        Err(e) if e.to_string().contains("ainda nao ha nada") && attempt < 3 => {
            attempt += 1;
            tokio::time::sleep(Duration::from_secs(3)).await;
        }
        r => break r,
    }
}?;

Prevention

When it happens

Trigger: Calling save_replay() less than ~5-10 seconds after starting a replay recording, so the only segment on disk is still being written (or none exist yet).

Common situations: User starts recording and immediately clicks 'save replay'; very short replay_seconds value; slow disk writes delaying the first segment flush.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/6bc09099f6ff2b8d. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/screen_record.rs:466

    let mut segs: Vec<(std::time::SystemTime, PathBuf)> = std::fs::read_dir(&ring)?
        .flatten()
        .filter_map(|e| {
            let p = e.path();
            let m = e.metadata().ok()?;
            if p.extension().map(|x| x == "mp4").unwrap_or(false) && m.len() > 0 {
                Some((m.modified().ok()?, p))
            } else {
                None
            }
        })
        .collect();
    segs.sort();
    // O último segmento ainda está sendo escrito; pega os anteriores.
    if segs.len() > 1 {
        segs.pop();
    }
    if segs.is_empty() {
        return Err(anyhow!("ainda nao ha nada no buffer"));
    }
    let want = (opts.replay_seconds.max(10) / 5) as usize;
    let chosen: Vec<PathBuf> = segs
        .iter()
        .rev()
        .take(want)
        .map(|(_, p)| p.clone())
        .collect::<Vec<_>>()
        .into_iter()
        .rev()
        .collect();
    let list = ring.join("concat.txt");
    std::fs::write(
        &list,
        chosen
            .iter()
            .map(|p| format!("file '{}'", p.to_string_lossy().replace('\'', "'\\''")))
            .collect::<Vec<_>>()

View on GitHub (pinned to 8600b91f42)