fix(scheduler): mark orphaned live assets error immediately when recorder stops
When a capture sidecar crashes before finalize() runs (e.g. wrong node,
filter error, hardware fault), the asset stays 'live' indefinitely — library
shows 'Recording' badge for up to 120 minutes until the stale-timeout fires.
Add an orphan check that runs every scheduler tick: if an asset is 'live'
and its recorder is 'stopped', mark it 'error' immediately. This runs before
the 120-minute staleness guard so the library clears within 15 seconds.
🤖 Generated with Claude Code
This commit is contained in:
parent
08be8fea77
commit
f218650b85
1 changed files with 18 additions and 0 deletions
|
|
@ -135,6 +135,24 @@ async function tick() {
|
|||
}
|
||||
}
|
||||
|
||||
// Orphaned live assets: recorder stopped but asset still 'live'.
|
||||
// Happens when the capture sidecar crashes before finalize() runs.
|
||||
// Mark error immediately so the library doesn't show "Recording" forever.
|
||||
const orphanResult = await client.query(
|
||||
`UPDATE assets a
|
||||
SET status = 'error', updated_at = NOW()
|
||||
FROM recorders r
|
||||
WHERE a.status = 'live'
|
||||
AND a.display_name = r.current_session_id
|
||||
AND r.status = 'stopped'
|
||||
RETURNING a.id, a.display_name`
|
||||
);
|
||||
if (orphanResult.rows.length > 0) {
|
||||
for (const row of orphanResult.rows) {
|
||||
console.warn(`[scheduler] orphaned live asset (recorder stopped): ${row.id} (${row.display_name})`);
|
||||
}
|
||||
}
|
||||
|
||||
const LIVE_TIMEOUT_MINUTES = parseInt(process.env.LIVE_ASSET_TIMEOUT_MINUTES || '120', 10);
|
||||
const staleResult = await client.query(
|
||||
`UPDATE assets
|
||||
|
|
|
|||
Loading…
Reference in a new issue