ferd/erlang-history

delay on history being saved

nhooyr opened this issue · 4 comments

I got confused on this, I think it should be made clear in README.md

ferd commented

I have no idea what this means

In iex, if I press CTRL+C it says

BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution

if you press ctrl+c again history will not be saved. But if you press a and then enter, history will be saved.

Or if you only press CTRL+\ then history will also be saved.

ferd commented

This is more or less a race condition because the disk_log library writes buffered data to disk, and I am not calling fsync on every single operation. Usually if there's been 1 or 2 seconds of delay between the writing of the command and the exit things will be fine. You'll specifically risk dropping it if you quickly enter and leave, but that would only be the last line of the bunch.

Ah you are right, it has nothing to do with how I exit, I just have to leave after a few seconds.