move catch statement
This commit is contained in:
parent
3a59ba214d
commit
c14c54bd65
2 changed files with 8 additions and 8 deletions
|
@ -7,13 +7,8 @@ import { FirehoseSubscriptionBase, getOpsByType } from './util/subscription'
|
||||||
export class FirehoseSubscription extends FirehoseSubscriptionBase {
|
export class FirehoseSubscription extends FirehoseSubscriptionBase {
|
||||||
async handleEvent(evt: RepoEvent) {
|
async handleEvent(evt: RepoEvent) {
|
||||||
if (!isCommit(evt)) return
|
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.
|
// This logs the text of every post off the firehose.
|
||||||
// Just for fun :)
|
// Just for fun :)
|
||||||
|
|
|
@ -39,7 +39,9 @@ export abstract class FirehoseSubscriptionBase {
|
||||||
async run(subscriptionReconnectDelay: number) {
|
async run(subscriptionReconnectDelay: number) {
|
||||||
try {
|
try {
|
||||||
for await (const evt of this.sub) {
|
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
|
// update stored cursor every 20 events or so
|
||||||
if (isCommit(evt) && evt.seq % 20 === 0) {
|
if (isCommit(evt) && evt.seq % 20 === 0) {
|
||||||
await this.updateCursor(evt.seq)
|
await this.updateCursor(evt.seq)
|
||||||
|
@ -47,7 +49,10 @@ export abstract class FirehoseSubscriptionBase {
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('repo subscription errored', err)
|
console.error('repo subscription errored', err)
|
||||||
setTimeout(() => this.run(subscriptionReconnectDelay), subscriptionReconnectDelay)
|
setTimeout(
|
||||||
|
() => this.run(subscriptionReconnectDelay),
|
||||||
|
subscriptionReconnectDelay,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue