diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go index 6a48ce6..6a9ae64 100644 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -72,13 +72,15 @@ func New( } lifecycle.Append(fx.Hook{ - OnStart: func(startCtx context.Context) error { - ctx, cancel := context.WithCancel( - context.WithoutCancel(startCtx), - ) + OnStart: func(_ context.Context) error { + // Use context.Background() — the fx startup context + // expires after startup completes, so deriving from it + // would cancel the watcher immediately. The watcher's + // lifetime is controlled by w.cancel in OnStop. + ctx, cancel := context.WithCancel(context.Background()) w.cancel = cancel - go w.Run(ctx) + go w.Run(ctx) //nolint:contextcheck // intentionally not derived from startCtx return nil },