zui icon indicating copy to clipboard operation
zui copied to clipboard

Abrupt app kill causes loss of unsaved state (need autosave)

Open philrz opened this issue 2 years ago • 1 comments

While testing with recent Brim (commit 00ad8da in Dev mode at the moment), I happened to stop the app by hitting Control-C in the window I launched it from without having first politely closed it via Command-Q first in the app window. I noticed that this caused the loss of state changes that had accumulated in the app since I'd launched it, including connection config to a remote lake, imported queries, renamed entires in the Query Library, and query History entries. I found the same loss happened when running Brim GA v0.28.0 if I killed it via kill -9.

I bounced this finding off @mason-fish and he confirmed this is expected behavior at the moment:

The connection settings along with the rest of the state are written to file when you close the app the regular way (command-q, close from dock, or close through top menu). Ctrl-c or any other signal-based process ending will result in unsaved state.

While I respect that abrupt process deaths like kill -9 should be very rare nowadays, in this era when common tools like Google Docs auto-save, I suspect users would take for granted that the time window for such state loss should be much narrower. Not sure if there's a big performance hit to doing state saves for every little operation, but perhaps there's a way to do it periodically, e.g., every X seconds and/or after Y changes have been made without a state save?

philrz avatar Jan 10 '22 20:01 philrz

Yeah this is a good idea. That sounds frustrating to lose all that work.

jameskerr avatar Jan 10 '22 22:01 jameskerr

Verified in Brim commit 8c9908b.

As shown in the attached video, now if I make several state changes and abruptly hit Control-C in the window from which I launched into Dev mode, when I relaunch via yarn start the changes are all still intact.

https://user-images.githubusercontent.com/5934157/186755607-ad86431e-5fb6-4bad-ac94-b95653a3369d.mp4

Thanks @jameskerr!

philrz avatar Aug 25 '22 19:08 philrz