Skip to content

Comments

fix: resolve memory leak in useReconnectCountdown hook#38841

Merged
ggazzo merged 1 commit intoRocketChat:developfrom
Makeepan-dev:fix/reconnect-countdown-leak
Feb 20, 2026
Merged

fix: resolve memory leak in useReconnectCountdown hook#38841
ggazzo merged 1 commit intoRocketChat:developfrom
Makeepan-dev:fix/reconnect-countdown-leak

Conversation

@Makeepan-dev
Copy link
Contributor

@Makeepan-dev Makeepan-dev commented Feb 20, 2026

Proposed changes

This PR resolves a memory leak in apps/meteor/client/components/connectionStatus/useReconnectCountdown.ts.

The Issue:

The setInterval used to manage the reconnect countdown timer was not being properly cleared when the component unmounted. Because the interval ID was stored in a useRef (reconnectionTimerRef.current), if the component unmounted while the status was 'waiting', the timer would continue running orphaned in the background.

The Fix:

  • Added a proper return cleanup function to the useEffect hook.
  • Cleared the interval explicitly using reconnectionTimerRef.current.
  • Defensively reset the ref to undefined to ensure a clean state initialization on subsequent renders.

Issue(s)

Found via static analysis auditing for unhandled subscription/listener cleanups. (No existing issue number).

Steps to test or reproduce

  1. Force the Rocket.Chat client into a disconnected/reconnecting state so the useReconnectCountdown component mounts and status becomes 'waiting'.
  2. Trigger an unmount of the component while the countdown is actively running.
  3. Observe via React DevTools or memory profiling that the interval no longer continues executing in the background.

Further comments

The fix defensively checks for the existence of reconnectionTimerRef.current before calling clearInterval and resets the reference, ensuring no stale closures or ghost intervals persist.

Task: ARCH-1978

@Makeepan-dev Makeepan-dev requested a review from a team as a code owner February 20, 2026 12:40
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 20, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@CLAassistant
Copy link

CLAassistant commented Feb 20, 2026

CLA assistant check
All committers have signed the CLA.

@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2026

⚠️ No Changeset found

Latest commit: cd1dd0f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@KevLehman KevLehman added the contrib: valid A valid contribution where maintainers will review based on priority label Feb 20, 2026
@ggazzo ggazzo added this to the 8.2.0 milestone Feb 20, 2026
@ggazzo
Copy link
Member

ggazzo commented Feb 20, 2026

/jira ARCH-1935

@ggazzo ggazzo merged commit 4fa4be7 into RocketChat:develop Feb 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contrib: valid A valid contribution where maintainers will review based on priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants