Skip to content

[storage] 快速切换项目会取消待写入的自动保存 #3

Description

@jamiesun

Context Boundary

  • Repo/module: talkincode/GameKit, IndexedDB autosave in src/studio/store.tsx and src/lib/storage.ts
  • Version/commit: main, 9eb811e7bc3db3193b57609425723c478e438d32
  • Runtime: browser UI with a 350 ms debounced write
  • OS/browser: not recorded; source-level path
  • Dependencies/config: IndexedDB; no feature flag involved

Expectation vs. Reality

Expected: Switching projects does not discard dirty edits, and the UI reports Saved only after the IndexedDB transaction has committed.

Actual: The autosave effect schedules saveProject after 350 ms and clears that timer in its cleanup. Switching projects changes the project dependency, so the previous project's pending timer is cancelled without flushing the edit. In addition, saveProject resolves on the individual put request's success rather than waiting for the transaction's complete event, so the save indicator does not explicitly represent transaction commit.

Reproduction Path

  1. Open a project and change a file.
  2. Before the 350 ms debounce finishes (while the UI says Saving), immediately open another project.
  3. Reopen the original project or reload GameKit and inspect the file.
  4. To verify commit semantics, exercise a test IndexedDB transaction that succeeds at request level but aborts before commit; ensure the UI never reports Saved for it.

Minimal reproduction: edit A, start the autosave timer, switch to B before it fires, then reload A from IndexedDB.

Blast Radius

  • Affected users/paths: recent edits made immediately before switching projects or leaving the page; failed/aborted IndexedDB writes.
  • Frequency: navigation inside the debounce window, or a transaction that aborts after its request callback.
  • Severity rationale: silent loss of the most recent edit and a potentially premature Saved state; recommend P1 for project data durability.
  • Workaround: wait until the save indicator shows Saved before switching projects.

Evidence

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions