2 Commits

Author SHA1 Message Date
b9d6763adb Merge branch 'main' into fix/issue-53-startup-context
All checks were successful
check / check (push) Successful in 46s
2026-03-02 00:32:37 +01:00
clawbot
27d2a69026 fix: use context.Background() for watcher goroutine lifetime
All checks were successful
check / check (push) Successful in 31s
The OnStart hook previously derived the watcher's context from startCtx
via context.WithoutCancel(). While WithoutCancel strips cancellation,
using context.Background() makes the intent explicit: the watcher's
monitoring loop must outlive the fx startup phase and is controlled
solely by the cancel func called in OnStop.

Closes #53
2026-03-01 14:57:02 -08:00

View File

@@ -72,13 +72,15 @@ func New(
} }
lifecycle.Append(fx.Hook{ lifecycle.Append(fx.Hook{
OnStart: func(startCtx context.Context) error { OnStart: func(_ context.Context) error {
ctx, cancel := context.WithCancel( // Use context.Background() — the fx startup context
context.WithoutCancel(startCtx), // 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 w.cancel = cancel
go w.Run(ctx) go w.Run(ctx) //nolint:contextcheck // intentionally not derived from startCtx
return nil return nil
}, },