Skip to content

fix: avoid browser tabs content scripts memory leak - #864

Merged
ACTCD merged 2 commits into
mainfrom
fix/863/content-scripts-memory-leak
Aug 30, 2025
Merged

fix: avoid browser tabs content scripts memory leak#864
ACTCD merged 2 commits into
mainfrom
fix/863/content-scripts-memory-leak

Conversation

@ACTCD

@ACTCD ACTCD commented Aug 30, 2025

Copy link
Copy Markdown
Collaborator

fix #863

ACTCD added 2 commits August 30, 2025 13:25
`browser.runtime.onMessage` listeners seems to prevent content scripts recycle from causing memory leaks
@ACTCD
ACTCD requested a review from Copilot August 30, 2025 13:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a memory leak issue in browser tab content scripts by properly managing event listeners and preventing accumulation of orphaned listeners when tabs become hidden or inactive.

  • Adds proper cleanup for runtime message listeners using visibility state tracking
  • Implements the { once: true } option for one-time event listeners
  • Manually removes event listeners for document state changes to prevent accumulation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/ext/content-scripts/entry-userscripts.js Adds memory leak prevention through proper event listener cleanup and once-only DOM events
src/ext/content-scripts/entry-script-market.js Implements visibility-based listener management and removes unnecessary variable reset

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/ext/content-scripts/entry-userscripts.js
Comment thread src/ext/content-scripts/entry-script-market.js
@ACTCD
ACTCD merged commit 879b272 into main Aug 30, 2025
1 check passed
@ACTCD
ACTCD deleted the fix/863/content-scripts-memory-leak branch August 30, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants