Skip to content

Commit e763292

Browse files
committed
fix: lost errors in some publications
1 parent f855c11 commit e763292

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

meteor/server/api/deviceTriggers/RundownsObserver.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { literal } from '@sofie-automation/corelib/dist/lib'
55
import { MongoFieldSpecifierOnesStrict } from '@sofie-automation/corelib/dist/mongo'
66
import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
77
import { PromiseDebounce } from '../../publications/lib/PromiseDebounce'
8+
import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
9+
import { logger } from '../../logging'
810

911
const REACTIVITY_DEBOUNCE = 20
1012

@@ -24,15 +26,19 @@ export class RundownsObserver {
2426
#disposed = false
2527

2628
readonly #triggerUpdateRundownContent = new PromiseDebounce(async () => {
27-
if (this.#disposed) return
29+
try {
30+
if (this.#disposed) return
2831

29-
if (!this.#changed) return
30-
this.#cleanup?.()
32+
if (!this.#changed) return
33+
this.#cleanup?.()
3134

32-
const changed = this.#changed
33-
this.#cleanup = await changed(this.rundownIds)
35+
const changed = this.#changed
36+
this.#cleanup = await changed(this.rundownIds)
3437

35-
if (this.#disposed) this.#cleanup?.()
38+
if (this.#disposed) this.#cleanup?.()
39+
} catch (e) {
40+
logger.error(`Error in RundownsObserver triggerUpdateRundownContent: ${stringifyError(e)}`)
41+
}
3642
}, REACTIVITY_DEBOUNCE)
3743

3844
private constructor(onChanged: ChangedHandler) {

meteor/server/publications/lib/PromiseDebounce.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class PromiseDebounce<TResult = void, TArgs extends unknown[] = []> {
3838

3939
/**
4040
* Trigger an execution, but don't report the result.
41+
* Warning: If the function throws an error, that will not be logged or reported to the caller
4142
*/
4243
trigger = (...args: TArgs): void => {
4344
// If an execution is 'imminent', don't do anything

meteor/server/publications/lib/rundownsObserver.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { Rundowns } from '../../collections'
99
import { PromiseDebounce } from './PromiseDebounce'
1010
import type { MongoQuery } from '@sofie-automation/corelib/dist/mongo'
1111
import type { Rundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
12+
import { logger } from '../../logging'
13+
import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
1214

1315
const REACTIVITY_DEBOUNCE = 20
1416

@@ -27,17 +29,21 @@ export class RundownsObserver implements Meteor.LiveQueryHandle {
2729
#disposed = false
2830

2931
readonly #triggerUpdateRundownContent = new PromiseDebounce(async () => {
30-
if (this.#disposed) return
31-
if (!this.#changed) return
32-
this.#cleanup?.()
33-
this.#cleanup = undefined
34-
35-
const changed = this.#changed
36-
this.#cleanup = await changed(this.rundownIds)
37-
38-
if (this.#disposed) {
32+
try {
33+
if (this.#disposed) return
34+
if (!this.#changed) return
3935
this.#cleanup?.()
4036
this.#cleanup = undefined
37+
38+
const changed = this.#changed
39+
this.#cleanup = await changed(this.rundownIds)
40+
41+
if (this.#disposed) {
42+
this.#cleanup?.()
43+
this.#cleanup = undefined
44+
}
45+
} catch (e) {
46+
logger.error(`Error in RundownsObserver triggerUpdateRundownContent: ${stringifyError(e)}`)
4147
}
4248
}, REACTIVITY_DEBOUNCE)
4349

0 commit comments

Comments
 (0)