matcha icon indicating copy to clipboard operation
matcha copied to clipboard

BUG: Potential goroutine leak in IDLE watcher cleanup

Open andrinoff opened this issue 7 months ago • 1 comments

Describe the bug In fetcher/idle.go, Watch() creates goroutines but comment "Let old connection tear down in the background" suggests goroutines may not be properly waited on, risking leaks if connections don't close cleanly.

To reproduce Examine fetcher/idle.go lines 48-60:

// Stop existing watcher for this account if any
if existing, ok := w.watchers[account.ID]; ok {
    close(existing.stop)
    delete(w.watchers, account.ID)
    // Let old connection tear down in the background
}

If old connection hangs, goroutine never exits.

Expected behavior Use WaitGroup or ensure goroutines terminate within timeout.

Additional context

  • Good first issue
  • StopAllAndWait() exists but only called on shutdown
  • Long-running background goroutines can accumulate

Suggested fix: Add timeout-based cleanup or WaitGroup tracking.

OS All platforms

andrinoff avatar Apr 21 '26 09:04 andrinoff

This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.

floatpanebot avatar May 22 '26 06:05 floatpanebot