Skip to content

fix: memory leaks fix #1707 #1708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

maksimr
Copy link

@maksimr maksimr commented Jun 23, 2025

Fixes #1707

@Copilot Copilot AI review requested due to automatic review settings June 23, 2025 10:51
Copy link

changeset-bot bot commented Jun 23, 2025

⚠️ No Changeset found

Latest commit: d1386ac

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes memory leaks by ensuring that observers and asynchronous tasks are properly torn down using AbortControllers and cleanup functions. Key changes include renaming and updating the mutation observer API, integrating AbortSignal across snapshot and mutation flows, and adding cleanup logic to abort pending operations.

Reviewed Changes

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

Show a summary per file
File Description
packages/rrweb/src/record/shadow-dom-manager.ts Renames observer variable to removeObserver for clarity and proper cleanup
packages/rrweb/src/record/observer.ts Updates the API to return a teardown function and renames mutationObserver
packages/rrweb/src/record/mutation.ts Introduces a new AbortController to cancel serialization and ensures cleanup
packages/rrweb/src/record/index.ts Adds/reinitializes an AbortController before snapshot operations
packages/rrweb-snapshot/src/snapshot.ts Adds AbortSignal support to various asynchronous load functions
Comments suppressed due to low confidence (2)

packages/rrweb-snapshot/src/snapshot.ts:1296

  • Consider adding a comment to clarify why a new AbortController is created in the snapshot function, which will help future maintainers understand the design decision.
    signal = new AbortController().signal,

packages/rrweb/src/record/index.ts:380

  • [nitpick] It would be helpful to document the lifecycle of the abortController here, explaining why abort() is called at this point to improve overall code maintainability.
    abortController.abort();

@maksimr maksimr changed the title fix: memory leaks (#1707) fix: memory leaks #1707 fix Jun 23, 2025
@maksimr maksimr changed the title fix: memory leaks #1707 fix fix: memory leaks fix #1707 Jun 23, 2025
@maksimr
Copy link
Author

maksimr commented Jun 23, 2025

@YunFeng0817 @Juice10 Hi, I hope you're doing well. Could you please look at this PR with timer and memory leaks. Thx! 🥂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Memory leak and high CPU usage for link with ref preload
1 participant