fix(daemon): defer probeCancel so a panic mid-diagnostic still releases ctx
Some checks failed
CI / Test (push) Failing after 8s
CI / Build (push) Failing after 1s
CI / Build-1 (push) Failing after 1s
CI / Build-2 (push) Failing after 1s
CI / Build-3 (push) Failing after 1s
CI / Build-4 (push) Failing after 1s
CI / Build-5 (push) Failing after 1s
CI / Lint (push) Failing after 1s
CI / Coverage (push) Failing after 1s
CI / Vet (push) Failing after 1s

DetectHWAccelDiagnostic spawns subprocess calls; an unexpected panic
(broken ffmpeg binary, OOM mid-exec) would otherwise leave the
WithTimeout context dangling until natural expiry. defer keeps the
goroutine + timer reachable until runDaemonStart returns, but on a
long-lived daemon that's the process lifetime anyway — same effective
cost, with the safety guarantee.
This commit is contained in:
Deivid Soto 2026-05-27 14:11:24 +02:00
parent eb109f70ac
commit d913e66527

View file

@ -152,8 +152,8 @@ func runDaemonStart() error {
// startup forever.
ffmpegResolved, _ := mediainfo.ResolveFFmpeg(cfg.Library.FFmpegPath)
probeCtx, probeCancel := context.WithTimeout(context.Background(), 10*time.Second)
defer probeCancel() // guard against a panic inside DetectHWAccelDiagnostic
hwDiag := engine.DetectHWAccelDiagnostic(probeCtx, ffmpegResolved)
probeCancel()
log.Println(hwDiag.LogLine())
hwAccelPick := hwDiag.Pick
maxTranscodeHeight := 1080