Skip to content

Commit f6d8290

Browse files
committed
chore: minor fixes after code review
1 parent f1f77fa commit f6d8290

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/job-worker/src/playout/setNext.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,16 @@ export async function setNextPart(
6060
while (moveNextToPart) {
6161
// Ensure that we aren't stuck in an infinite loop. If this while loop is being run for a part twice, then the blueprints are behaving oddly and will likely get stuck
6262
// Instead of throwing and causing a larger failure, we can stop processing here, and leave something as next
63-
const nextedId = moveNextToPart.selectedPart?._id ?? null
64-
if (attemptedPartIds.has(nextedId)) {
65-
logger.error(`Blueprint onSetAsNext callback moved the next part ${attemptedPartIds.size}, forming a loop`)
63+
const nextPartId = moveNextToPart.selectedPart?._id ?? null
64+
if (attemptedPartIds.has(nextPartId)) {
65+
logger.error(
66+
`Blueprint onSetAsNext callback moved the next part "${nextPartId}" (trace: ${JSON.stringify(
67+
Array.from(attemptedPartIds.values())
68+
)}), forming a loop`
69+
)
6670
break
6771
}
68-
attemptedPartIds.add(nextedId)
72+
attemptedPartIds.add(nextPartId)
6973

7074
moveNextToPart = await setNextPartAndCheckForPendingMoveNextPart(
7175
context,
@@ -97,7 +101,7 @@ async function setNextPartAndCheckForPendingMoveNextPart(
97101
rawNextPart: ReadonlyDeep<Omit<SelectNextPartResult, 'index'>> | PlayoutPartInstanceModel | null,
98102
setManually: boolean,
99103
nextTimeOffset?: number | undefined
100-
) {
104+
): Promise<{ selectedPart: ReadonlyDeep<DBPart> | null } | undefined> {
101105
if (rawNextPart) {
102106
if (!playoutModel.playlist.activationId)
103107
throw new Error(`RundownPlaylist "${playoutModel.playlist._id}" is not active`)
@@ -185,10 +189,10 @@ async function executeOnSetAsNextCallback(
185189
context: JobContext
186190
) {
187191
const rundownOfNextPart = playoutModel.getRundown(newPartInstance.partInstance.rundownId)
188-
if (!rundownOfNextPart) return null
192+
if (!rundownOfNextPart) return undefined
189193

190194
const blueprint = await context.getShowStyleBlueprint(rundownOfNextPart.rundown.showStyleBaseId)
191-
if (!blueprint.blueprint.onSetAsNext) return null
195+
if (!blueprint.blueprint.onSetAsNext) return undefined
192196

193197
const showStyle = await context.getShowStyleCompound(
194198
rundownOfNextPart.rundown.showStyleVariantId,

0 commit comments

Comments
 (0)