Retry pending queue after SSE recovery
This commit is contained in:
1 parent
50601996af
commit
c5e85f1857
2 files changed
+11
-1
No files matched your search
+9
@@ -92,6 +92,7 @@ class RemoteOpenClawRepository(
|
||||
private var messageStore by mutableStateOf<Map<String, List<ChatMessage>>>(emptyMap())
|
||||
private var streamStatusStore by mutableStateOf<Map<String, String>>(emptyMap())
|
||||
private val sessionSortKeyStore = mutableMapOf<String, Long>()
|
||||
private val streamRecoveryQueueDrainPending = mutableSetOf<String>()
|
||||
private val attachmentRetryStore = mutableMapOf<String, AttachmentRetryPayload>()
|
||||
private val attachmentOpenStore = mutableMapOf<String, AttachmentOpenPayload>()
|
||||
private val textRetryStore = mutableMapOf<String, TextRetryPayload>()
|
||||
@@ -628,6 +629,11 @@ class RemoteOpenClawRepository(
|
||||
try {
|
||||
streamStatusStore = streamStatusStore + (sessionId to "live")
|
||||
syncSessionStreamStatus(sessionId)
|
||||
if (streamRecoveryQueueDrainPending.remove(sessionId)) {
|
||||
runCatching { retryAutoRecoverableMessages(sessionId) }
|
||||
runCatching { drainPendingTextQueue(sessionId) }
|
||||
runCatching { drainPendingAttachmentQueue(sessionId) }
|
||||
}
|
||||
sseStream.connect(sessionId).collect { event ->
|
||||
when (event) {
|
||||
is SessionStreamEvent.Snapshot -> {
|
||||
@@ -722,6 +728,7 @@ class RemoteOpenClawRepository(
|
||||
is SessionStreamEvent.Failed -> {
|
||||
val dto = event.payload
|
||||
if (!dto.recoverable) {
|
||||
streamRecoveryQueueDrainPending.remove(sessionId)
|
||||
streamStatusStore = streamStatusStore + (sessionId to "failed")
|
||||
syncSessionStreamStatus(sessionId)
|
||||
messageStore = messageStore + (
|
||||
@@ -737,6 +744,7 @@ class RemoteOpenClawRepository(
|
||||
updateSessionPreview(sessionId, previewMessage(messageStore[sessionId].orEmpty()))
|
||||
return@collect
|
||||
}
|
||||
streamRecoveryQueueDrainPending.add(sessionId)
|
||||
streamStatusStore = streamStatusStore + (sessionId to "reconnecting")
|
||||
syncSessionStreamStatus(sessionId)
|
||||
// recoverable: will retry via outer while loop
|
||||
@@ -746,6 +754,7 @@ class RemoteOpenClawRepository(
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (_: Throwable) {
|
||||
streamRecoveryQueueDrainPending.add(sessionId)
|
||||
streamStatusStore = streamStatusStore + (sessionId to "reconnecting")
|
||||
syncSessionStreamStatus(sessionId)
|
||||
delay(1500)
|
||||
|
||||
Reference in new issue
Block a user