Skip to content

Ignore IndexedDB failures during garbage collection #3015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/firestore/src/local/lru_garbage_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
import { PersistencePromise } from './persistence_promise';
import { TargetData } from './target_data';

const LOG_TAG = 'LruGarbageCollector';

/**
* Persistence layers intending to use LRU Garbage collection should have reference delegates that
* implement this interface. This interface defines the operations that the LRU garbage collector
Expand Down Expand Up @@ -265,13 +267,19 @@ export class LruScheduler implements GarbageCollectionScheduler {
this.gcTask = this.asyncQueue.enqueueAfterDelay(
TimerId.LruGarbageCollection,
delay,
() => {
async () => {
this.gcTask = null;
this.hasRun = true;
return localStore
.collectGarbage(this.garbageCollector)
.then(() => this.scheduleGC(localStore))
.catch(ignoreIfPrimaryLeaseLoss);
try {
await localStore.collectGarbage(this.garbageCollector);
} catch (e) {
if (e.name === 'IndexedDbTransactionError') {
logDebug(LOG_TAG, 'Ignoring IndexedDB error during garbage collection: ', e);
} else {
await ignoreIfPrimaryLeaseLoss(e);
}
}
await this.scheduleGC(localStore);
}
);
}
Expand Down