4716fba90272
M4/QUA-006: log takeVaultSnapshot failures and notify popup on quota
- time
- 2026-05-16 04:02 UTC · 5 months ago
- machine
- koh2
- parent
- 76fd3d0637f7
↓ peach-browser-4716fba9.tar.gzatlas at this save
files changed1 file
src/background/vault.ts+26 −3src/background/vault.ts+26 −3
@@ -2068,9 +2068,19 @@20682068 20692069 history.snapshots = [snapshot, ...history.snapshots].slice(0, HISTORY_MAX);20702070 await chrome.storage.local.set({ [HISTORY_KEY]: history });2071- } catch {2071+ } catch (err) {20722072 // Non-fatal — history must never block a save. A failed snapshot just20732073 // means the user loses one rung of the safety ladder for this write.2074+ // M4/QUA-006: log so the failure is visible; if it looks like a quota2075+ // problem, notify the popup so the user can prune history themselves.2076+ console.warn('[Peach] takeVaultSnapshot failed:', err);2077+ if (String(err).includes('QUOTA') || String(err).includes('quota')) {2078+ try {2079+ await chrome.runtime.sendMessage({ type: 'VAULT_STORAGE_QUOTA_WARNING' });2080+ } catch {2081+ // popup may be closed; surfaced via console.warn above2082+ }2083+ }20742084 }20752085 }20762086 @@ -2262,8 +2272,21 @@22622272 throw new Error('invalid_incoming_vault_blob');22632273 }22642274 2265- // Snapshot before overwriting — failure is non-fatal2266- await takeVaultSnapshot('sync_received').catch(() => {});2275+ // Snapshot before overwriting — non-fatal but user-visible.2276+ // M4/QUA-006: a silent snapshot failure leaves the user without their2277+ // safety net for an incoming sync write; surface it.2278+ try {2279+ await takeVaultSnapshot('sync_received');2280+ } catch (snapshotErr) {2281+ console.warn('[Peach] vault snapshot failed during sync:', snapshotErr);2282+ if (String(snapshotErr).includes('QUOTA') || String(snapshotErr).includes('quota')) {2283+ try {2284+ await chrome.runtime.sendMessage({ type: 'VAULT_STORAGE_QUOTA_WARNING' });2285+ } catch {2286+ // popup may be closed; surfaced via console.warn above2287+ }2288+ }2289+ }22672290 22682291 await writeSlot(SLOT_A, a);22692292 if (hasValidVaultSchema(b)) await writeSlot(SLOT_B, b);