Skip to content

Commit

Permalink
move skip logic to subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
Bossett committed Sep 4, 2024
1 parent c76910e commit 0523b79
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/util/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@ export abstract class FirehoseSubscriptionBase {
async run(subscriptionReconnectDelay: number) {
try {
for await (const evt of this.sub) {
try {
this.handleEvent(evt) // no longer awaiting this
} catch (err) {
console.error('repo subscription could not handle message', err)
const commit = evt as Commit

if (Array.isArray(commit.ops) && commit.ops.length > 0) {
const [collection] = commit.ops[0].path.split('/')
if (includedRecords.has(collection)) {
try {
this.handleEvent(evt) // no longer awaiting this
} 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)
Expand Down

0 comments on commit 0523b79

Please sign in to comment.