From d913e665278de19ac843092f718d425260ec3e42 Mon Sep 17 00:00:00 2001 From: Deivid Soto Date: Wed, 27 May 2026 14:11:24 +0200 Subject: [PATCH] fix(daemon): defer probeCancel so a panic mid-diagnostic still releases ctx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- internal/cmd/daemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/daemon.go b/internal/cmd/daemon.go index 28b948b..668ecff 100644 --- a/internal/cmd/daemon.go +++ b/internal/cmd/daemon.go @@ -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