Skip to content

fix(sseMultiplexer): clear localStorageClaimTimeout before setting to prevent timer accumulation #75

Description

@tmdeveloper007

Summary of What Needs to be Done

Fix a memory leak in src/utils/sseMultiplexer.js inside the claimLocalStorageLeadership() method. The method has a guard if (this.localStorageClaimTimeout || this.isLeader) return that prevents a new timeout from being set, but it does NOT cancel a previously set timeout. Repeated calls to claimLocalStorageLeadership leave orphaned timers in the browser timer queue.

Changes

At the start of claimLocalStorageLeadership, clear any existing this.localStorageClaimTimeout with clearTimeout before setting a new one. This ensures only one pending claim confirmation timer exists at a time.

Impact

Severity: Medium — Timer accumulation in long-running sessions with frequent leadership elections. In multi-tab scenarios with competing leaders, the queue can grow and contribute to memory pressure.

Please assign this task to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gssoc:approvedApproved for GSSoC contributionlevel:beginnerSmall, low-risk change (≤3 files, ≤50 lines)type:bugSomething is broken or incorrect

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions