Fix a potential crash caused by using old Sentry transactions. (#5459)

* Fix a deprecation warning.

* Remove unused method.

* Fix a crash caused by using old Sentry transactions.
This commit is contained in:
Doug
2026-04-21 17:14:17 +01:00
committed by GitHub
parent 2284719c52
commit ac2fdba3f1
2 changed files with 10 additions and 6 deletions

View File

@@ -1027,22 +1027,22 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
// This callback is only executed once during the entire run of the program to avoid
// multiple callbacks if there are multiple crash events to send (see method documentation)
options.onCrashedLastRun = { event in
options.onLastRunStatusDetermined = { status, event in
guard case .didCrash = status, let event else { return }
MXLog.error("Sentry detected a crash in the previous run: \(event.eventId.sentryIdString)")
bugReportService.lastCrashEventID = event.eventId.sentryIdString
}
// Any ongoing transactions will no longer be valid after calling SentrySDK.start so lets
// remove them and start over, otherwise the app will crash if finishTransaction is used.
ServiceLocator.shared.analytics.signpost.resetTransactions()
SentrySDK.start(options: options) // Swift
enableSentryLogging(enabled: options.enabled) // Rust
MXLog.info("Sentry configured (enabled: \(options.enabled))")
}
private func teardownSentry() {
SentrySDK.close()
MXLog.info("SentrySDK stopped")
}
private func processInlineReply(roomID: String, replyText: String) async {
guard let userSession else {
fatalError("User session not setup")

View File

@@ -75,6 +75,10 @@ class Signposter {
transactions[transactionName] = nil
}
func resetTransactions() {
transactions.removeAll()
}
// MARK: - Spans
func addSpan(_ spanName: SpanName, toTransaction transactionName: TransactionName) -> Span? {