Skip to content

Forced shutdown can cause confirmed saves to be lost or silently overwritten on reopen #146

Description

@RecursiveRegret

Issue

A forced shutdown exposed two durability gaps in the current save path:

  1. save_file_content may acknowledge a write before the OS flushes to disk, making recent saves non-durable on power loss.

  2. On reopen, restoreStateOnReopen replays rawContent from LevelDB tab state, which can diverge from the on-disk file with no conflict detection and no revision trail to fall back to. The combination means a user can lose work with no recovery path.

Context

Markpad was used to edit and save an .md file on Windows, then the PC was force shut down. After reboot, the file contents did not match the version I expected.

  • I checked Markpad’s WebView/LevelDB local storage including 000003.ldb, 000006.ldb, 000007.log, LOG, LOG.old, and MANIFEST-000001.

  • I searched a copy of that folder for savedTabsData and for a distinctive missing-content token but found no recoverable prior content.

Proposed Fix

  1. Add an optional auto-save interval to reduce exposure between manual saves and forced shutdown.
  2. Persist a snapshot of tab state to LevelDB on each confirmed save, recoverable across sessions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions