fix(anki): preserve known-word cache when maturity fetch fails

- Catch errors from fetchKnownWordMaturityTierSets so a failed tier query no longer aborts the whole refresh
- Known words still cache; tiers just stay null until the next successful refresh
- Add regression test covering findNotes failure on a tier query
This commit is contained in:
2026-07-22 23:23:07 -07:00
parent 8a8a700ccb
commit a39ca2cbac
2 changed files with 41 additions and 5 deletions
+9 -4
View File
@@ -389,13 +389,18 @@ export class KnownWordCacheManager {
this.isRefreshingKnownWords = true;
try {
const noteFieldsById = await this.fetchKnownWordNoteFieldsById();
const tierSets = this.isMaturityTrackingEnabled()
? await fetchKnownWordMaturityTierSets(
let tierSets = null;
if (this.isMaturityTrackingEnabled()) {
try {
tierSets = await fetchKnownWordMaturityTierSets(
(query, options) => this.deps.client.findNotes(query, options),
this.getKnownWordQueryScopes().map((scope) => scope.query),
getMatureIntervalThresholdDays(this.deps.getConfig()),
)
: null;
);
} catch (error) {
log.warn('Failed to fetch known-word maturity tiers:', (error as Error).message);
}
}
const currentNoteIds = Array.from(noteFieldsById.keys()).sort((a, b) => a - b);
if (this.noteEntriesById.size === 0) {