Fix session transaction issue

This commit is contained in:
Fedor Indutny 2021-05-28 16:09:17 -07:00 committed by GitHub
parent 87c9151d70
commit fcaa34d67a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -820,7 +820,7 @@ export class SignalProtocolStore extends EventsMixin {
encodedAddresses: Array<string>,
{ zone = GLOBAL_ZONE }: SessionTransactionOptions = {}
): Promise<Array<SessionRecord>> {
return this.withZone(zone, 'loadSession', async () => {
return this.withZone(zone, 'loadSessions', async () => {
const sessions = await Promise.all(
encodedAddresses.map(async address =>
this.loadSession(address, { zone })
@ -1100,7 +1100,7 @@ export class SignalProtocolStore extends EventsMixin {
item.archiveCurrentState();
await this.storeSession(entry.fromDB.id, item);
await this.storeSession(entry.fromDB.id, item, { zone });
},
zone
);

View file

@ -1477,6 +1477,16 @@ describe('SignalProtocolStore', () => {
assert.deepEqual(order, [1, 2, 3]);
});
it('should not deadlock in archiveSiblingSessions', async () => {
const id = `${number}.1`;
const sibling = `${number}.2`;
await store.storeSession(id, getSessionRecord(true));
await store.storeSession(sibling, getSessionRecord(true));
await store.archiveSiblingSessions(id, { zone });
});
});
describe('Not yet processed messages', () => {