From 7a024cec3b96a809f7c064bb1e81ce615c989850 Mon Sep 17 00:00:00 2001 From: Daniel Arroyo Date: Thu, 9 Jul 2026 00:04:44 -0400 Subject: [PATCH] fix: use context.Background() in TriggerRun so job outlives HTTP request r.Context() is cancelled when the HTTP handler returns (after 201 is sent), causing the job to be immediately marked as cancelled_shutdown before WoL even runs. Use context.Background() so the job goroutine runs independently of the HTTP request lifecycle. --- internal/api/handlers_jobs.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/api/handlers_jobs.go b/internal/api/handlers_jobs.go index 22434f9..3c50088 100644 --- a/internal/api/handlers_jobs.go +++ b/internal/api/handlers_jobs.go @@ -1,6 +1,7 @@ package api import ( + "context" "database/sql" "encoding/json" "fmt" @@ -160,7 +161,7 @@ func (h *JobHandler) TriggerRun(w http.ResponseWriter, r *http.Request) { slog.Error("job run goroutine panicked", "job_id", jobID, "panic", r) } }() - h.engine.Run(r.Context(), jobID, pairID) + h.engine.Run(context.Background(), jobID, pairID) }() jobRepo := models.NewJobRepository(h.db)