Skip to content

Comments

Fixed useNow hook#37

Merged
spietras merged 1 commit intomainfrom
use-now
Feb 10, 2026
Merged

Fixed useNow hook#37
spietras merged 1 commit intomainfrom
use-now

Conversation

@spietras
Copy link
Member

No description provided.

@spietras spietras requested a review from Copilot February 10, 2026 20:49
@spietras spietras self-assigned this Feb 10, 2026
@spietras spietras added the bug Something isn't working label Feb 10, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical memory leak bug in the useNow hook. The hook manages a shared timestamp that updates every second using a reference counter to track how many components are using it. The original implementation failed to decrement the counter during cleanup, preventing the timer from ever being cleared once multiple components had mounted, causing a resource leak.

Changes:

  • Fixed the cleanup function to properly decrement the reference counter before checking if cleanup should proceed
  • Changed the condition from checking counter > 1 to decrementing first then checking counter > 0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@spietras spietras merged commit b04a8bd into main Feb 10, 2026
8 checks passed
@spietras spietras deleted the use-now branch February 10, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant