diff --git a/src/subscription.ts b/src/subscription.ts index ab18bd9..0422a03 100644 --- a/src/subscription.ts +++ b/src/subscription.ts @@ -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 :) diff --git a/src/util/subscription.ts b/src/util/subscription.ts index 01d5013..769843b 100644 --- a/src/util/subscription.ts +++ b/src/util/subscription.ts @@ -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, + ) } }