Handle different pending failures

This commit is contained in:
Eric Bailey
2024-05-15 16:56:31 -05:00
parent 9dd837ceab
commit 02692225e3
+14 -4
View File
@@ -288,6 +288,7 @@ export class Convo {
if (this.convo) {
this.status = ConvoStatus.Ready
this.refreshConvo()
this.batchRetryPendingMessages()
} else {
this.status = ConvoStatus.Initializing
this.setup()
@@ -841,15 +842,26 @@ export class Convo {
}
async batchRetryPendingMessages() {
if (this.pendingMessageFailure === 'unrecoverable') return
// reset if present, and recoverable
if (this.pendingMessageFailure === 'recoverable') {
this.pendingMessageFailure = null
this.commit()
}
const messageArray = Array.from(this.pendingMessages.values())
if (messageArray.length === 0) return
logger.debug(
`Convo: retrying ${this.pendingMessages.size} pending messages`,
`Convo: batch retrying ${this.pendingMessages.size} pending messages`,
{},
logger.DebugContext.convo,
)
try {
// throw new Error('UNCOMMENT TO TEST RETRY')
const messageArray = Array.from(this.pendingMessages.values())
const {data} = await networkRetry(2, () => {
return this.agent.api.chat.bsky.convo.sendMessageBatch(
{
@@ -990,8 +1002,6 @@ export class Convo {
retry:
this.pendingMessageFailure === 'recoverable'
? () => {
this.pendingMessageFailure = null
this.commit()
this.batchRetryPendingMessages()
}
: undefined,