Skip to content

fix(app): clean up online/offline listeners on Browse unmount - #7213

Open
waliser wants to merge 1 commit into
modrinth:mainfrom
waliser:fix/browse-online-offline-listener-leak
Open

fix(app): clean up online/offline listeners on Browse unmount#7213
waliser wants to merge 1 commit into
modrinth:mainfrom
waliser:fix/browse-online-offline-listener-leak

Conversation

@waliser

@waliser waliser commented Aug 19, 2026

Copy link
Copy Markdown

Summary

  • Browse.vue registers window.addEventListener('online'/'offline', ...) but never removes the listeners.
  • The router only keeps LibraryPage alive via <KeepAlive include="LibraryPage"> (App.vue), so Browse.vue unmounts every time the user navigates away (e.g. into a project) and remounts on return.
  • Each remount leaks a new pair of closures on window, pinning the whole component setup scope from being garbage collected. Over a browsing session this accumulates continuously, contributing to reports of high/growing memory usage while browsing mods on Linux (related: Linux-specific performance, graphical, or crashing issues [MEGA-ISSUE] #3057).

Fix

Store the handlers in named refs, remove them in onBeforeUnmount, matching the cleanup pattern already used elsewhere in the app (e.g. ContextMenu.vue, QuickInstanceSwitcher.vue).

Test plan

  • Confirmed no other unmatched addEventListener/removeEventListener pairs were introduced
  • Would appreciate a maintainer/CI check on the frontend build, since I verified this locally by reading the router keep-alive config and lifecycle hooks, not with the full app-frontend dev toolchain

Browse.vue registers window 'online'/'offline' listeners but never
removes them. Since only LibraryPage is kept alive by the router,
Browse unmounts every time the user navigates away (e.g. into a
project) and remounts on return, leaking a new pair of closures (and
pinning the whole component scope) on window each time. Over a
browsing session this accumulates continuously.
@github-actions

Copy link
Copy Markdown
Contributor

Pull request changelog

App

Added

Changed

Deprecated

Removed

Fixed

Security

Website

Added

Changed

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant