atuin icon indicating copy to clipboard operation
atuin copied to clipboard

Panic shortly after importing

Open conradludgate opened this issue 3 years ago • 1 comments

Performing these two actions consistently gets me a panic

 oon@altair  ~/code/rust/atuin   main  rm ~/.local/share/atuin/history.db
 oon@altair  ~/code/rust/atuin   main  atuin import zsh
        Atuin
======================
          🌍
       🐘🐘🐘🐘
          🐢
======================
Importing history...
Importing history from zsh
Import complete!

Followed by Up

 oon@altair  ~/code/rust/atuin   main  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: OutOfRangeError(())', src/command/search.rs:45:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

https://github.com/ellie/atuin/blob/de2e34ac50/src/command/search.rs#L45

This seems to occur when chrono::Utc::now().sub(h.timestamp) is negative. I'm not sure why, perhaps there's a discrepancy in the ~/.zsh_history file where the timestamps are possibly a couple seconds in the future

    pub fn to_std(&self) -> Result<StdDuration, OutOfRangeError> {
        if self.secs < 0 {
            return Err(OutOfRangeError(()));
        }
        Ok(StdDuration::new(self.secs as u64, self.nanos as u32))
    }

conradludgate avatar May 10 '21 09:05 conradludgate

I'm experiencing the same, also with atuin import zsh using the cargo-installed version.

loveencounterflow avatar May 13 '21 08:05 loveencounterflow

I believe we fixed this a while ago

ellie avatar Oct 08 '22 04:10 ellie