Skip to content

Memory leak in OAuth authentication flow #1125

@Anshumancanrock

Description

@Anshumancanrock

Description:

Memory leak in OAuth authentication flow where event listeners and interval timers are not cleaned up when login succeeds. The cleanup only happens when the popup is manually closed by the user.

Steps to reproduce:

  1. Enable OAuth authentication (authFlow: 'OAUTH')
  2. Click the login button to trigger loginWithRocketChatOAuth()
  3. Complete OAuth login successfully
  4. Check browser's event listeners and active intervals

Expected behavior:

After successful OAuth login, both the message event listener and the interval timer should be immediately removed from memory.

Actual behavior:

The event listener on window and setInterval continue running even after successful login. They only get cleaned up when the interval detects the popup is closed (up to 1 second delay), and if timing is unlucky, they may persist indefinitely. This causes memory leaks when users authenticate multiple times in a session.

Additionally, if the user closes the OAuth popup without completing login, the promise never resolves or rejects, leaving the app in a hanging state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions