Skip to content

Commit 04b3998

Browse files
committed
fix: lost errors in some publications
1 parent c7d4a4d commit 04b3998

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
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: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Meteor } from 'meteor/meteor'
22
import { RundownId, RundownPlaylistId, StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
33
import { Rundowns } from '../../collections'
44
import { PromiseDebounce } from './PromiseDebounce'
5+
import { logger } from '../../logging'
6+
import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
57

68
const REACTIVITY_DEBOUNCE = 20
79

@@ -20,14 +22,22 @@ export class RundownsObserver implements Meteor.LiveQueryHandle {
2022
#disposed = false
2123

2224
readonly #triggerUpdateRundownContent = new PromiseDebounce(async () => {
23-
if (this.#disposed) return
24-
if (!this.#changed) return
25-
this.#cleanup?.()
26-
27-
const changed = this.#changed
28-
this.#cleanup = await changed(this.rundownIds)
29-
30-
if (this.#disposed) this.#cleanup?.()
25+
try {
26+
if (this.#disposed) return
27+
if (!this.#changed) return
28+
this.#cleanup?.()
29+
this.#cleanup = undefined
30+
31+
const changed = this.#changed
32+
this.#cleanup = await changed(this.rundownIds)
33+
34+
if (this.#disposed) {
35+
this.#cleanup?.()
36+
this.#cleanup = undefined
37+
}
38+
} catch (e) {
39+
logger.error(`Error in RundownsObserver triggerUpdateRundownContent: ${stringifyError(e)}`)
40+
}
3141
}, REACTIVITY_DEBOUNCE)
3242

3343
private constructor(onChanged: ChangedHandler) {

0 commit comments

Comments
 (0)