Skip to content

[Code Quality] Fix timer leak in CheckForUpdatesAsync — use time.NewTimer + defer Stop() #47678

Description

@github-actions

Description

In pkg/cli/update_check.go around line 270, time.After(100ms) is used in a select statement. When the ctx.Done() case fires first, the time.After channel is not released until the timer fires 100 ms later, causing a GC-delayed resource leak.

Suggested Changes

Replace time.After(100 * time.Millisecond) with time.NewTimer and add defer timer.Stop().

Files Affected

  • pkg/cli/update_check.go (~line 270, inside CheckForUpdatesAsync)

Success Criteria

  • time.After replaced with time.NewTimer + defer timer.Stop()
  • Timer variable scoped correctly within the goroutine
  • Existing tests pass

Source

Extracted from [repository-quality] Goroutine Lifecycle Hygiene #47586

Priority

Medium

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · sonnet46 · 67.5 AIC · ⌖ 5.28 AIC · ⊞ 7.1K ·

  • expires on Jul 24, 2026, 5:18 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