Never let a dropped event stream close the app
Both screens that follow a stream retried an `ApiException` and let everything else through, and `Sse.run` opened its connection on a line outside the `try` that maps failures onto that type. So a failure at open time, or anything the framing did not expect, reached the top of the app and closed it -- from a screen whose own comment says failures there are deliberately quiet, because the listing already carries every state the stream would have brought. The open moves inside the guarded region, and both loops now retry on any exception while rethrowing `CancellationException`, which is the screen leaving rather than a failure -- swallowing that one would leave the loop reconnecting to a stream nobody is watching. This is hardening on the path that runs when a screen with a stream opens, not a diagnosed fix: an import list loading against a server missing the events route, and against 121 real transcripts, does not crash here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
778b2e3b04
commit
8257030280
3 files changed
+30
-6
No files matched your search
@@ -718,8 +718,15 @@ fun SessionScreen(settings: ServerSettings, summary: SessionSummary, onBack: ()
|
||||
apply(entry)
|
||||
}
|
||||
}
|
||||
} catch (e: ApiException) {
|
||||
streamError = e.message
|
||||
} catch (e: kotlinx.coroutines.CancellationException) {
|
||||
// Leaving the screen or going below STARTED. Not a failure, and
|
||||
// swallowing it would leave this loop reconnecting forever.
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
// Any failure, not only an [ApiException]: the stream reconnects from its
|
||||
// cursor, so there is nothing a failure here can cost that is worth
|
||||
// closing the app over. Reported on the screen either way.
|
||||
streamError = e.message ?: e::class.simpleName
|
||||
} finally {
|
||||
stream.close()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user