Skip to content

BUG: Potential goroutine leak in IDLE watcher cleanup #731

@andrinoff

Description

@andrinoff

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions