jlcodes99/cockpit-tools · warning
[AccountStore] 清理超限缓存失败:
Error message
[AccountStore] 清理超限缓存失败:
What it means
scheduleAccountStoreQuotaRecovery defers a setTimeout(0) cleanup that removes the account store cache key and two legacy keys to recover from a QuotaExceededError during a persist write. If even the removals fail, the error is warned and the schedule flag is reset in finally.
Source
Thrown at src/stores/useAccountStore.ts:40
error.name === 'QuotaExceededError' ||
error.code === 22 ||
error.code === 1014
);
}
const message = String(error);
return message.includes('QuotaExceededError') || message.includes('quota');
}
function scheduleAccountStoreQuotaRecovery(storageKey: string) {
if (typeof window === 'undefined' || accountStoreQuotaCleanupScheduled) return;
accountStoreQuotaCleanupScheduled = true;
setTimeout(() => {
try {
localStorage.removeItem(storageKey);
localStorage.removeItem(LEGACY_ACCOUNTS_CACHE_KEY);
localStorage.removeItem(LEGACY_CURRENT_ACCOUNT_CACHE_KEY);
} catch (error) {
console.warn('[AccountStore] 清理超限缓存失败:', error);
} finally {
accountStoreQuotaCleanupScheduled = false;
}
}, 0);
}
const accountStoreStorage = createJSONStorage(() => ({
getItem: (name: string) => {
try {
return localStorage.getItem(name);
} catch (error) {
console.warn(`[AccountStore] 读取持久化数据失败: ${name}`, error);
return null;
}
},
setItem: (name: string, value: string) => {
try {
localStorage.setItem(name, value);View on GitHub (pinned to 1ed8b77992)
Solutions
- Verify storage availability once at startup and disable persistence when unavailable
- Clear site data manually to reset the quota
- Keep the finally-based flag reset so recovery can be rescheduled later
- Reduce persisted state size (partialize the zustand store) to avoid quota pressure
Example fix
// before
} catch (error) {
console.warn('[AccountStore] 清理超限缓存失败:', error);
}
// after
} catch (error) {
console.warn('[AccountStore] 清理超限缓存失败:', error);
console.warn('[AccountStore] 请手动清除站点数据以恢复账号缓存');
} Defensive patterns
Strategy: try-catch
Validate before calling
function storageWritable(): boolean {
try { localStorage.setItem('__probe__', '1'); localStorage.removeItem('__probe__'); return true; }
catch { return false; }
} Try / catch
try {
localStorage.removeItem(storageKey);
localStorage.removeItem(LEGACY_ACCOUNTS_CACHE_KEY);
localStorage.removeItem(LEGACY_CURRENT_ACCOUNT_CACHE_KEY);
} catch (error) {
console.warn('[AccountStore] 清理超限缓存失败:', error);
} finally {
accountStoreQuotaCleanupScheduled = false;
} Prevention
- Use partialize on the persist store to keep persisted state small
- Probe storage availability once and disable persistence if blocked
- Keep cleanup idempotent and always reset the scheduling flag in finally
- Advise manual site-data clearing when automatic recovery fails
When it happens
Trigger: localStorage.removeItem throws during quota recovery — storage disabled, page in a blocked-storage context, or the environment throwing on any storage access after a quota violation.
Common situations: Safari private mode where all storage APIs throw; embedded webviews with storage partitioned off; persistent quota pressure from other large keys.
Related errors
- [TraeAutoCheckin] 保存自动签到日志失败:
- [WorkbuddyAutoCheckin] 本地缓存保存失败:
- [AccountStore] 写入持久化数据失败: ${name}
- [AccountStore] 本地缓存空间不足,已自动清理账号缓存并回退为仅内存态。
- Failed to save active page to localStorage:
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/5c048e5b97cfa996.
Report an issue: GitHub.