🟠 high - bug
File: cmd/root/flags.go (line 162)
Code
stop := context.AfterFunc(ctx, func() {
_ = ln.Close()
})
cleanup := func() {
stop()
_ = ln.Close()
}
return ln, cleanup, nil
Problem
The ln.Close() is called twice in the cleanup function. Once directly as _ = ln.Close() and again via stop(), which also calls _ = ln.Close(). This redundant call might not cause an immediate error because net.Listener.Close() is often idempotent, but it's unnecessary and can be a sign of a logic error.
Suggested Fix
Remove the redundant _ = ln.Close() call from the cleanup function. The stop() function already handles closing the listener.
Found by nightly codebase scan