move catch statement

This commit is contained in:
dholms 2024-10-31 16:41:46 -05:00
parent 3a59ba214d
commit c14c54bd65
2 changed files with 8 additions and 8 deletions

View file

@ -7,13 +7,8 @@ import { FirehoseSubscriptionBase, getOpsByType } from './util/subscription'
export class FirehoseSubscription extends FirehoseSubscriptionBase {
async handleEvent(evt: RepoEvent) {
if (!isCommit(evt)) return
const ops = await getOpsByType(evt).catch(e => {
console.error('repo subscription could not handle message', e)
return undefined
})
if (!ops) return
const ops = await getOpsByType(evt)
// This logs the text of every post off the firehose.
// Just for fun :)

View file

@ -39,7 +39,9 @@ export abstract class FirehoseSubscriptionBase {
async run(subscriptionReconnectDelay: number) {
try {
for await (const evt of this.sub) {
this.handleEvent(evt)
this.handleEvent(evt).catch((err) => {
console.error('repo subscription could not handle message', err)
})
// update stored cursor every 20 events or so
if (isCommit(evt) && evt.seq % 20 === 0) {
await this.updateCursor(evt.seq)
@ -47,7 +49,10 @@ export abstract class FirehoseSubscriptionBase {
}
} catch (err) {
console.error('repo subscription errored', err)
setTimeout(() => this.run(subscriptionReconnectDelay), subscriptionReconnectDelay)
setTimeout(
() => this.run(subscriptionReconnectDelay),
subscriptionReconnectDelay,
)
}
}