Skip to content

[cleanup] Replace time.Tick() with time.NewTicker() to prevent goroutine leaks - #1279

Merged
manugarg merged 1 commit into
mainfrom
fix/replace-time-tick-with-ticker
Mar 29, 2026
Merged

manugarg merged 1 commit into
mainfrom
fix/replace-time-tick-with-ticker

Conversation

@manugarg

@manugarg manugarg commented Mar 29, 2026 •

Copy link
Copy Markdown
Contributor

Note that these goroutine leaks will never be a reality as time.Tick is called in goroutines that never end. It's a good cleanup anyway though.

time.Tick() creates a ticker that can never be stopped, leaking the
underlying goroutine and timer for the lifetime of the process. Replace
all 13 instances with time.NewTicker() + defer ticker.Stop().

Also adds context cancellation support to http server's statsKeeper.
@manugarg
manugarg force-pushed the fix/replace-time-tick-with-ticker branch from 3a0c54d to f9d4821 Compare March 29, 2026 01:50
@manugarg manugarg changed the title Replace time.Tick() with time.NewTicker() to prevent goroutine leaks [cleanup] Replace time.Tick() with time.NewTicker() to prevent goroutine leaks Mar 29, 2026
@manugarg
manugarg merged commit 2b77fd0 into main Mar 29, 2026
11 of 12 checks passed
@manugarg
manugarg deleted the fix/replace-time-tick-with-ticker branch March 29, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant