jlcodes99/cockpit-tools · warning
[AccountStore] 忽略异常空账号列表,保留本地缓存账号
Error message
[AccountStore] 忽略异常空账号列表,保留本地缓存账号
What it means
A defensive console.warn in useAccountStore's fetchAccounts: accountService.listAccounts() resolved to an empty array while the store already holds cached accounts and no explicit allowNextEmptyAccountList flag was set. The store keeps the cached accounts and aborts the update, guarding against backend responses that are spuriously empty.
Source
Thrown at src/stores/useAccountStore.ts:205
const now = Date.now();
// 如果正在请求中,且距离上次请求不足 DEBOUNCE_MS,复用现有 Promise
if (fetchAccountsPromise && now - fetchAccountsLastTime < DEBOUNCE_MS) {
return fetchAccountsPromise;
}
fetchAccountsLastTime = now;
fetchAccountsPromise = (async () => {
const requestId = ++fetchAccountsSeq;
set({ loading: true, error: null });
try {
const accounts = await accountService.listAccounts();
if (requestId !== fetchAccountsSeq) {
return;
}
if (accounts.length === 0 && get().accounts.length > 0 && !allowNextEmptyAccountList) {
console.warn('[AccountStore] 忽略异常空账号列表,保留本地缓存账号');
set({ loading: false });
return;
}
allowNextEmptyAccountList = false;
set({ accounts, loading: false });
} catch (e) {
if (requestId !== fetchAccountsSeq) {
return;
}
set({ error: String(e), loading: false });
} finally {
if (requestId === fetchAccountsSeq) {
allowNextEmptyAccountList = false;
}
// 请求完成后延迟清除 Promise,允许短时间内的后续调用也复用结果
setTimeout(() => {
if (requestId === fetchAccountsSeq) {
fetchAccountsPromise = null;View on GitHub (pinned to 1ed8b77992)
Solutions
- Retry fetching accounts; transient empty responses are safely ignored.
- Re-authenticate if the backend session expired — verify with an authenticated endpoint.
- If accounts were genuinely removed, use the store's logout/reset path which sets allowNextEmptyAccountList.
- Inspect the raw listAccounts response for API shape/pagination regressions.
- Clear the local cache deliberately if it is confirmed stale.
Defensive patterns
Strategy: validation
Validate before calling
const accounts = await accountService.listAccounts();
if (accounts.length === 0 && get().accounts.length > 0 && !allowNextEmptyAccountList) {
console.warn('[AccountStore] ignoring anomalous empty account list');
set({ loading: false });
return;
} Type guard
function isNonEmptyAccounts(v: unknown): v is Account[] {
return Array.isArray(v) && v.length > 0;
} Prevention
- Always route intentional empty transitions through allowNextEmptyAccountList.
- Check authentication state before fetching; an empty list often hides an expired session.
- Keep a last-known-good snapshot and timestamp for diagnostics when the guard trips.
When it happens
Trigger: listAccounts() returns [] while get().accounts.length > 0 and allowNextEmptyAccountList is false, with the request still current (requestId check passed).
Common situations: Backend session silently expired so the list comes back empty instead of 401; provider API change altering the list endpoint shape; backend restart mid-request; network middleware dropping the payload body.
Related errors
- [AccountStore] 忽略异常空当前账号,保留本地缓存当前账号: ${target}
- [Provider Store] 忽略异常空当前账号,保留本地缓存: ${cacheKey}
- [Provider Store] 忽略异常空账号列表,保留本地缓存: ${cacheKey}
- accounts_section_required
- codex.localAccess.noEligibleAccountsSelected
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/6ebb6de9b6d2c39a.
Report an issue: GitHub.