Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element-R: reduce log spam when checking server key backup #3826

Merged
merged 5 commits into from
Oct 26, 2023

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Oct 23, 2023

Fixes a lot of spam in the logs about "uncaught in promise: No room_keys found".


This change is marked as an internal change (Task), so will not be included in the changelog.

@richvdh richvdh requested a review from a team as a code owner October 23, 2023 16:47
@richvdh richvdh added the T-Task Tasks for the team like planning label Oct 23, 2023
@richvdh richvdh requested review from germain-gg and t3chguy October 23, 2023 16:47
@@ -460,7 +460,7 @@ export class RustBackupDecryptor implements BackupDecryptor {
for (const [sessionId, sessionData] of Object.entries(ciphertexts)) {
try {
const decrypted = JSON.parse(
await this.decryptionKey.decryptV1(
this.decryptionKey.decryptV1(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is slightly separate, but a cleanup while I was in the area.

decryptionKey.decryptV1 doesn't return a promise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I have seen it now that I use WebStorm. I am wondering if you shouldn't update the bindings to make it async?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an await immediate() in 131c524 to make sure we don't block the event loop.

Fixes a lot of spam in the logs about "uncaught in promise: No room_keys
found".
Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the cleaning, it was mostly copy pasted from legacy. Just a few comments

spec/integ/crypto/megolm-backup.spec.ts Show resolved Hide resolved
@@ -460,7 +460,7 @@ export class RustBackupDecryptor implements BackupDecryptor {
for (const [sessionId, sessionData] of Object.entries(ciphertexts)) {
try {
const decrypted = JSON.parse(
await this.decryptionKey.decryptV1(
this.decryptionKey.decryptV1(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I have seen it now that I use WebStorm. I am wondering if you shouldn't update the bindings to make it async?

const path = encodeUri("/room_keys/keys/$roomId/$sessionId", {
$roomId: targetRoomId,
$sessionId: targetSessionId,
this.queryKeyBackup(targetRoomId, targetSessionId).catch((e) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to check if we have the private key before marking the check as attempted (sessionLastCheckAttemptedTime = now). Because if we attempt to get the key and you don't have the private key yet (verification not yet done) it will not retry until KEY_BACKUP_CHECK_RATE_LIMIT. So when you verify after login, you'll have to wait?
KEY_BACKUP_CHECK_RATE_LIMIT isn't that high currently, so maybe not too important though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to check if we have the private key before marking the check as attempted (sessionLastCheckAttemptedTime = now).

The problem with that is that it is racy: if two calls to startQueryKeyBackupRateLimited happen in quick succession (eg, because there are two messages in a sync response), then both will check sessionLastCheckAttemptedTime and find it ok, and go on to make a backup request. We need to make sure there is no await between the check and the update on sessionLastCheckAttemptedTime.

@richvdh richvdh added this pull request to the merge queue Oct 25, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 25, 2023
@richvdh richvdh added this pull request to the merge queue Oct 26, 2023
@richvdh
Copy link
Member Author

richvdh commented Oct 26, 2023

Merged via the queue into develop with commit 07a9eb3 Oct 26, 2023
19 checks passed
@richvdh richvdh deleted the rav/element-r/silence_backup_spam branch October 26, 2023 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Task Tasks for the team like planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants