Skip to content

Commit 280f738

Browse files
authored
Merge pull request #3515 from element-hq/feature/bma/fixRageshakeCrash
Fix crash when session is deleted on another client
2 parents 349e2bb + fa3796d commit 280f738

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListPresenter.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import io.element.android.features.roomlist.impl.search.RoomListSearchEvents
3939
import io.element.android.features.roomlist.impl.search.RoomListSearchState
4040
import io.element.android.libraries.architecture.AsyncData
4141
import io.element.android.libraries.architecture.Presenter
42+
import io.element.android.libraries.core.bool.orFalse
4243
import io.element.android.libraries.designsystem.utils.snackbar.SnackbarDispatcher
4344
import io.element.android.libraries.designsystem.utils.snackbar.collectSnackbarMessageAsState
4445
import io.element.android.libraries.featureflag.api.FeatureFlagService
@@ -218,7 +219,10 @@ class RoomListPresenter @Inject constructor(
218219
}
219220
}
220221
val needsSlidingSyncMigration by produceState(false) {
221-
value = client.isNativeSlidingSyncSupported() && !client.isUsingNativeSlidingSync()
222+
value = runCatching {
223+
// Note: this can fail when the session is destroyed from another client.
224+
client.isNativeSlidingSyncSupported() && !client.isUsingNativeSlidingSync()
225+
}.getOrNull().orFalse()
222226
}
223227
return when {
224228
showEmpty -> RoomListContentState.Empty

libraries/network/src/main/kotlin/io/element/android/libraries/network/interceptors/FormattedJsonHttpLogger.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ internal class FormattedJsonHttpLogger(
3434
// It can be only the case if we log the bodies of Http requests.
3535
if (level != HttpLoggingInterceptor.Level.BODY) return
3636

37+
if (message.length > 100_000) {
38+
Timber.d("Content is too long (${message.length} chars) to be formatted as JSON")
39+
return
40+
}
41+
3742
if (message.startsWith("{")) {
3843
// JSON Detected
3944
try {

0 commit comments

Comments
 (0)