Skip to content

[Code Quality] Add goleak to goroutine-heavy test packages to prevent goroutine leak regressions #48086

Description

@github-actions

Description

The codebase has goroutine lifecycle improvements underway (e.g., docker_images.go, update_check.go), but there is currently zero usage of goleak in any test package. Without goleak, goroutine leaks can be introduced silently in future changes.

Suggested Changes

  • Add github.com/uber-go/goleak as a test dependency
  • Add goleak.VerifyTestMain(m) to TestMain in packages that launch goroutines:
    • pkg/cli/ (contains update_check.go, docker_images.go, bootstrap_profile_*.go)
    • pkg/console/ (spinner goroutine)
  • Add defer goleak.VerifyNone(t) to individual tests that exercise goroutine-launching paths
  • Ensure all goroutine lifecycle fixes already merged pass under goleak

Files Affected

  • pkg/cli/update_check_test.go (add or update TestMain)
  • pkg/cli/docker_images_test.go (add or update TestMain)
  • pkg/console/spinner_test.go (add leak assertion)
  • go.mod / go.sum (new test dependency)

Success Criteria

  • goleak is imported in ≥3 test packages covering goroutine-launching code
  • All existing tests pass with leak detection enabled
  • CI fails if a future change introduces a goroutine leak

Source

Extracted from DeepReport Intelligence Briefing - 2026-07-24 discussion #47817

Priority

Medium — prevents regression of in-flight goroutine lifecycle fixes

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · sonnet46 · 54.2 AIC · ⌖ 8.34 AIC · ⊞ 7.2K ·

  • expires on Jul 26, 2026, 5:20 PM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions