fix(persistence): harden coerceEpoch null guard + autosave catch rollback

- coerceEpoch: early-return fallback on null/undefined input (was falling
  through to new Date(null) → epoch 0, surfacing as 1970-01-01 in the
  stories list); also unify the tail branch to Number.isFinite for
  consistency with the number-type fast path
- autosave .catch: roll back lastSavedFingerprintRef on unexpected throw
  so the next session change retries instead of silently marking the
  content as saved

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yuanzonghao
2026-06-27 18:36:26 +08:00
parent da74e3e763
commit cf6e08aec4
2 changed files with 7 additions and 5 deletions
+5 -4
View File
@@ -902,10 +902,11 @@ function PlayInner() {
lastSavedFingerprintRef.current = "";
}
})
// Defensive: saveStory is contracted never to throw, but if a future edit
// to this callback ever does, an unhandled rejection here would poison the
// chain and freeze ALL subsequent saves. Swallow to keep the chain alive.
.catch(() => {});
.catch(() => {
if (lastSavedFingerprintRef.current === fingerprint) {
lastSavedFingerprintRef.current = "";
}
});
}, [session]);
useEffect(() => {
currentSceneRef.current = currentScene;