-
Notifications
You must be signed in to change notification settings - Fork 739
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
Catching EnsureOlmSessionsForDevicesAction errors #4229
Catching EnsureOlmSessionsForDevicesAction errors #4229
Conversation
…cryption flow - we currently can't do much but log here as we've asynchronously start the fallback flow, catching the error at least stops a hard crash
@@ -146,29 +146,36 @@ internal class EventDecryptor @Inject constructor( | |||
|
|||
// offload this from crypto thread (?) | |||
cryptoCoroutineScope.launch(coroutineDispatchers.computation) { | |||
val ensured = ensureOlmSessionsForDevicesAction.handle(mapOf(senderId to listOf(deviceInfo)), force = true) | |||
runCatching { ensureOlmSessionsForDevicesAction.handle(mapOf(senderId to listOf(deviceInfo)), force = true) }.fold( | |||
onSuccess = { sendDummyToDevice(ensured = it, deviceInfo, senderId) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted the logic out to its own function to avoid too many levels of indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
Could you also update sendToDeviceTask.execute(sendToDeviceParams) and use executeRetry (3 retries?)
ALso in the EnsureOlmSessionsForDevicesAction, we should probably executeWith retry the claim oneTimeKeysForUsersDeviceTask.execute(claimParams)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, maybe @BillCarsonFr can have a look too.
Can you add a small file for the changelog please?
withContext(coroutineDispatchers.io) { | ||
val sendToDeviceParams = SendToDeviceTask.Params(EventType.ENCRYPTED, sendToDeviceMap) | ||
try { | ||
sendToDeviceTask.executeRetry(sendToDeviceParams, remainingRetry = SEND_TO_DEVICE_RETRY_COUNT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sendToDeviceTask
is now executed with the ability to retry 3 times
@@ -72,7 +74,7 @@ internal class EnsureOlmSessionsForDevicesAction @Inject constructor( | |||
Timber.i("## CRYPTO | claimOneTimeKeysForUsersDevices() : $usersDevicesToClaim") | |||
|
|||
val claimParams = ClaimOneTimeKeysForUsersDeviceTask.Params(usersDevicesToClaim) | |||
val oneTimeKeys = oneTimeKeysForUsersDeviceTask.execute(claimParams) | |||
val oneTimeKeys = oneTimeKeysForUsersDeviceTask.executeRetry(claimParams, remainingRetry = ONE_TIME_KEYS_RETRY_COUNT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oneTimeKeysForUsersDeviceTask
is now executed with the ability to retry 3 times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still OK to me, @BillCarsonFr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, thx.
Fixes #3608
When failing to decrypt a
MXCRYPTO_ALGORITHM_OLM
event due toBAD_ENCRYPTED_MESSAGE
the app can crash if theensureOlmSessionsForDevicesAction
logic fails, which can happen if theclaimOneTimeKeysForUsersDevices
http request fails due to being offline.sendToDeviceTask
&oneTimeKeysForUsersDeviceTask
executions to retry 3 timesThe error handling logic is asynchronous executed meaning the main decryption flow isn't able to react to any further errors.
I've naively fixed this crash by simply catching the source of the error, similar to how the surrounding logic behaves.