Repository navigation
fix(persist): Protect session stores from stale and failed reads - #52
Merged
Merged
Conversation
A sync save waited at most one second for queued async updates and then wrote anyway, so a slower in-flight save could finish afterwards and overwrite it with an older snapshot. Sync updates now join the same queue and run with blocking I/O when their turn comes; if the queue does not drain in time they are withdrawn and reported as failed.
Read errors, undecodable JSON and unknown store versions were all treated as an empty store, so the next save, delete or rename replaced every existing session. Reads now return nil on failure, which aborts the update and leaves the cache untouched; only a missing file counts as empty. Reads also go to EOF on the opened descriptor instead of a size taken from an earlier stat, so a store replaced by an atomic rename is no longer truncated mid-read.
Numeric settings only had to be numbers within bounds, so a fractional persist.max_items passed validation and made the session item slice come back empty, and NaN slipped through every bounds check. These settings now reject fractions, NaN and infinities and fall back to the default with a warning that names it; ratios reject NaN as well.
Every other config section that must be a table is replaced with its defaults and the warning says so, but a non-table persist.auto was kept as is with a bare warning that did not say which settings applied. It now follows the same fallback and message, and the special-case options for that one field are gone.
… settings Document that an unreadable session store is never replaced with an empty one, that the save on leave gives up after waiting a second for earlier saves, and that numeric settings must be integers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
PeekstackSavehandler oron_donedoes not wait on its own caller.persist.max_items, which previously emptied saved sessions; ratios reject NaN too.ui.path.max_widthuses the same validator, and its warnings now name the fallback value.persist.autogets the same default fallback and warning as other sections.:help peekstackcover store read-failure protection, the save-on-leave timeout and integer-only numeric settings.