Skip to content

[MMU-UI] Memory leak in AuthGuard.canActivate() - unmanaged subscription on every route activation #138

@lakxy

Description

@lakxy

Description

AuthGuard.canActivate() calls this.http_service.currentLangugae$.subscribe() on every route activation with no corresponding unsubscribe. AuthGuard is a singleton and currentLangugae$ is a BehaviorSubject that never completes, so each navigation to a protected route adds a subscription that is never released.

The subscribed value current_language_set is never read or used anywhere in the guard logic, so the subscription has no effect at all.

Affected routes (7)

All routes using canActivate: [AuthGuard] in app-routing.module.ts:
/service, /servicePoint, /registrar, /nurse-doctor, /lab, /pharmacist, /datasync

Steps to reproduce

  1. Log in and open DevTools -> Memory tab, take a baseline heap snapshot.
  2. Navigate between the protected routes above around 10 times.
  3. Take a second heap snapshot and compare subscriber counts for currentLangugae$.
  4. Subscriber count grows with each navigation and nothing cleans up.

Validation

  • currentLangugae$ is new BehaviorSubject(...).asObservable() in http-service.service.ts and never completes, so subscribers are never auto-released.
  • current_language_set is only assigned (line 18), never read anywhere in the file.
  • No takeUntil, take(1), or unsubscribe() exists in the class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions