Skip to content

Commit a56c1df

Browse files
committed
chore: improve logging, for troubleshooting
1 parent 5e53676 commit a56c1df

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed

packages/job-worker/src/ingest/commit.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,27 @@ async function getSelectedPartInstances(
674674
})
675675
: []
676676

677+
const currentPartInstance = instances.find((inst) => inst._id === playlist.currentPartInfo?.partInstanceId)
678+
const nextPartInstance = instances.find((inst) => inst._id === playlist.nextPartInfo?.partInstanceId)
679+
const previousPartInstance = instances.find((inst) => inst._id === playlist.previousPartInfo?.partInstanceId)
680+
681+
if (playlist.currentPartInfo?.partInstanceId && !currentPartInstance)
682+
logger.error(
683+
`playlist.currentPartInfo is set, but PartInstance "${playlist.currentPartInfo?.partInstanceId}" was not found!`
684+
)
685+
if (playlist.nextPartInfo?.partInstanceId && !nextPartInstance)
686+
logger.error(
687+
`playlist.nextPartInfo is set, but PartInstance "${playlist.nextPartInfo?.partInstanceId}" was not found!`
688+
)
689+
if (playlist.previousPartInfo?.partInstanceId && !previousPartInstance)
690+
logger.error(
691+
`playlist.previousPartInfo is set, but PartInstance "${playlist.previousPartInfo?.partInstanceId}" was not found!`
692+
)
693+
677694
return {
678-
currentPartInstance: instances.find((inst) => inst._id === playlist.currentPartInfo?.partInstanceId),
679-
nextPartInstance: instances.find((inst) => inst._id === playlist.nextPartInfo?.partInstanceId),
680-
previousPartInstance: instances.find((inst) => inst._id === playlist.previousPartInfo?.partInstanceId),
695+
currentPartInstance,
696+
nextPartInstance,
697+
previousPartInstance,
681698
}
682699
}
683700

@@ -827,7 +844,16 @@ async function removeSegments(
827844
})
828845
}
829846
for (const segmentId of purgeSegmentIds) {
830-
logger.debug(`IngestModel: Removing segment "${segmentId}"`)
847+
logger.debug(
848+
`IngestModel: Removing segment "${segmentId}" (` +
849+
`previousPartInfo?.partInstanceId: ${newPlaylist.previousPartInfo?.partInstanceId},` +
850+
`currentPartInfo?.partInstanceId: ${newPlaylist.currentPartInfo?.partInstanceId},` +
851+
`nextPartInfo?.partInstanceId: ${newPlaylist.nextPartInfo?.partInstanceId},` +
852+
`previousPartInstance.segmentId: ${!previousPartInstance ? 'N/A' : previousPartInstance.segmentId},` +
853+
`currentPartInstance.segmentId: ${!currentPartInstance ? 'N/A' : currentPartInstance.segmentId},` +
854+
`nextPartInstance.segmentId: ${!nextPartInstance ? 'N/A' : nextPartInstance.segmentId}` +
855+
`)`
856+
)
831857
ingestModel.removeSegment(segmentId)
832858
}
833859
}

packages/job-worker/src/ingest/syncChangesToPartInstance.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { validateAdlibTestingPartInstanceProperties } from '../playout/adlibTest
3333
import { ReadonlyDeep } from 'type-fest'
3434
import { convertIngestModelToPlayoutRundownWithSegments } from './commit'
3535
import { PlayoutRundownModel } from '../playout/model/PlayoutRundownModel'
36+
import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
3637

3738
type PlayStatus = 'previous' | 'current' | 'next'
3839
type SyncedInstance = {
@@ -143,15 +144,26 @@ export async function syncChangesToPartInstances(
143144
if (!playoutRundownModelForPart)
144145
throw new Error(`Internal Error: playoutRundownModelForPart is undefined (it should never be)`)
145146

146-
const proposedPieceInstances = getPieceInstancesForPart(
147-
context,
148-
playoutModel,
149-
previousPartInstance,
150-
playoutRundownModelForPart,
151-
part,
152-
await piecesThatMayBeActive,
153-
existingPartInstance.partInstance._id
154-
)
147+
// TMP: wrap in try/catch for troubleshooting:
148+
let proposedPieceInstances: PieceInstance[] = []
149+
try {
150+
proposedPieceInstances = getPieceInstancesForPart(
151+
context,
152+
playoutModel,
153+
previousPartInstance,
154+
playoutRundownModelForPart,
155+
part,
156+
await piecesThatMayBeActive,
157+
existingPartInstance.partInstance._id
158+
)
159+
} catch (e) {
160+
161+
logger.error(`TROUBLESHOOTING: currentPartInstance: ${JSON.stringify(playoutModel.currentPartInstance)}`)
162+
logger.error(`TROUBLESHOOTING: nextPartInstance: ${JSON.stringify(playoutModel.nextPartInstance)}`)
163+
logger.error(`TROUBLESHOOTING: previousPartInstance: ${JSON.stringify(playoutModel.previousPartInstance)}`)
164+
165+
throw e
166+
}
155167

156168
logger.info(`Syncing ingest changes for part: ${partId} (orphaned: ${!!newPart})`)
157169

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ export function getPieceInstancesForPart(
352352
throw new Error(
353353
`Segment "${playingPartInstance.partInstance.segmentId}" in Rundown "${
354354
playingRundown.rundown._id
355-
}" not found! (other segments: ${JSON.stringify(playingRundown.segments.map((s) => s.segment._id))})`
355+
}" not found! (partInstanceId: "${playingPartInstance.partInstance._id}", other segments: ${JSON.stringify(playingRundown.segments.map((s) => s.segment._id))})`
356356
)
357357
}
358358
}

0 commit comments

Comments
 (0)