Skip to content
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
23 changes: 19 additions & 4 deletions contentcuration/contentcuration/frontend/shared/data/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Dexie from 'dexie';
import * as Sentry from '@sentry/vue';
import mapValues from 'lodash/mapValues';
import channel from './broadcastChannel';
import { CHANGES_TABLE, IGNORED_SOURCE, TABLE_NAMES } from './constants';
Expand Down Expand Up @@ -47,11 +48,25 @@ function runElection() {
elector.awaitLeadership().then(startSyncing);
elector.onduplicate = () => {
stopSyncing();
elector.die().then(runElection);
elector
.die()
.then(() => {
// manually reset reference to dead elector on the channel
// which is set within `createLeaderElection` and whose
// presence is also validated against, requiring its removal
channel._leaderElector = null;
return runElection();
})
.catch(Sentry.captureException);
};
}

export function initializeDB() {
setupSchema();
return db.open().then(runElection);
export async function initializeDB() {
try {
setupSchema();
await db.open();
await runElection();
} catch (e) {
Sentry.captureException(e);
}
}