Skip to content

Commit

Permalink
Fix lack of error handling in parts of backing store.
Browse files Browse the repository at this point in the history
Errors propagating here could cause the bot to have only partially
synced by propagating all the way up to the sync response handling in
the bot-sdk.

#691.
  • Loading branch information
Gnuxie committed Feb 2, 2025
1 parent bcfdfdf commit 8e22074
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/backingstore/better-sqlite3/SqliteRoomStateBackingStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class SqliteRoomStateBackingStore
this.ensureSchema();
}

public handleRevision(
private updateBackingStore(
revision: RoomStateRevision,
changes: StateChange[]
): void {
Expand Down Expand Up @@ -102,9 +102,37 @@ export class SqliteRoomStateBackingStore
});
const roomInfo = this.getRoomMeta(revision.room.toRoomIDOrAlias());
if (roomInfo === undefined) {
doCompleteWriteback();
try {
doCompleteWriteback();
} catch (e) {
log.error(
`Unable to create initial room state for ${revision.room.toPermalink()} into the room state backing store`,
e
);
}
} else {
replace(changes.map((change) => change.state));
try {
replace(changes.map((change) => change.state));
} catch (e) {
log.error(
`Unable to update the room state for ${revision.room.toPermalink()} as a result of ${changes.length} changes`,
e
);
}
}
}

public handleRevision(
revision: RoomStateRevision,
changes: StateChange[]
): void {
try {
this.updateBackingStore(revision, changes);
} catch (e) {
log.error(
`Unable to update the backing store for revision of the room ${revision.room.toPermalink()}`,
e
);
}
}

Expand Down

0 comments on commit 8e22074

Please sign in to comment.