diff --git a/.changeset/empty-lemons-move.md b/.changeset/empty-lemons-move.md new file mode 100644 index 0000000000..608d741f40 --- /dev/null +++ b/.changeset/empty-lemons-move.md @@ -0,0 +1,5 @@ +--- +'livekit-client': patch +--- + +Treat MissingKey as decryption failure to prevent spamming the logs diff --git a/src/e2ee/worker/FrameCryptor.ts b/src/e2ee/worker/FrameCryptor.ts index 507050ebde..7d44dd8593 100644 --- a/src/e2ee/worker/FrameCryptor.ts +++ b/src/e2ee/worker/FrameCryptor.ts @@ -360,6 +360,7 @@ export class FrameCryptor extends BaseFrameCryptor { } } catch (error) { if (error instanceof CryptorError && error.reason === CryptorErrorReason.InvalidKey) { + // emit an error if the key handler thinks we have a valid key if (this.keys.hasValidKey) { this.emit(CryptorEvent.Error, error); this.keys.decryptionFailure(); @@ -369,7 +370,7 @@ export class FrameCryptor extends BaseFrameCryptor { } } } else if (!this.keys.getKeySet(keyIndex) && this.keys.hasValidKey) { - // emit an error in case the key index is out of bounds but the key handler thinks we still have a valid key + // emit an error if the key index is out of bounds but the key handler thinks we still have a valid key workerLogger.warn(`skipping decryption due to missing key at index ${keyIndex}`); this.emit( CryptorEvent.Error, @@ -379,6 +380,7 @@ export class FrameCryptor extends BaseFrameCryptor { this.participantIdentity, ), ); + this.keys.decryptionFailure(); } }