diff --git a/src/e2ee/CryptoClient.ts b/src/e2ee/CryptoClient.ts index 0f6d8f63..a70aae4d 100644 --- a/src/e2ee/CryptoClient.ts +++ b/src/e2ee/CryptoClient.ts @@ -169,13 +169,12 @@ export class CryptoClient { await this.engine.lock.acquire(SYNC_LOCK_NAME, async () => { const syncResp = JSON.parse(await this.engine.machine.receiveSyncChanges(deviceMessages, deviceLists, otkCounts, unusedFallbackKeyAlgs)); - if (Array.isArray(syncResp)) { - const decryptedToDeviceMessages = syncResp[0]; - if (Array.isArray(decryptedToDeviceMessages)) { - for (const msg of decryptedToDeviceMessages as IToDeviceMessage[]) { - this.client.emit("to_device.decrypted", msg); - } + if (Array.isArray(syncResp) && syncResp.length === 2 && Array.isArray(syncResp[0])) { + for (const msg of syncResp[0] as IToDeviceMessage[]) { + this.client.emit("to_device.decrypted", msg); } + } else { + LogService.error("CryptoClient", "OlmMachine.receiveSyncChanges did not return an expected value of [to-device events, room key changes]"); } await this.engine.run();