Add retries to all handlers (#3935)

This commit is contained in:
Eric Bailey
2024-05-09 16:31:36 -05:00
committed by GitHub
parent becc708c61
commit 55fdbc7399
2 changed files with 90 additions and 73 deletions
+23 -18
View File
@@ -2,6 +2,7 @@ import {BskyAgent, ChatBskyConvoGetLog} from '@atproto-labs/api'
import EventEmitter from 'eventemitter3'
import {nanoid} from 'nanoid/non-secure'
import {networkRetry} from '#/lib/async/retry'
import {logger} from '#/logger'
import {DEFAULT_POLL_INTERVAL} from '#/state/messages/events/const'
import {
@@ -265,16 +266,18 @@ export class MessagesEventBus {
logger.debug(`${LOGGER_CONTEXT}: init`, {}, logger.DebugContext.convo)
try {
const response = await this.agent.api.chat.bsky.convo.listConvos(
{
limit: 1,
},
{
headers: {
Authorization: this.__tempFromUserDid,
const response = await networkRetry(2, () => {
return this.agent.api.chat.bsky.convo.listConvos(
{
limit: 1,
},
},
)
{
headers: {
Authorization: this.__tempFromUserDid,
},
},
)
})
// throw new Error('UNCOMMENT TO TEST INIT FAILURE')
const {convos} = response.data
@@ -358,16 +361,18 @@ export class MessagesEventBus {
// )
try {
const response = await this.agent.api.chat.bsky.convo.getLog(
{
cursor: this.latestRev,
},
{
headers: {
Authorization: this.__tempFromUserDid,
const response = await networkRetry(2, () => {
return this.agent.api.chat.bsky.convo.getLog(
{
cursor: this.latestRev,
},
},
)
{
headers: {
Authorization: this.__tempFromUserDid,
},
},
)
})
// throw new Error('UNCOMMENT TO TEST POLL FAILURE')