-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
base: master
Are you sure you want to change the base?
Conversation
Properly cleanup delayed snapshot work when record is stopped to prevent leaking timeout
|
There was a problem hiding this 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();
@YunFeng0817 @Juice10 Hi, I hope you're doing well. Could you please look at this PR with timer and memory leaks. Thx! 🥂 |
Fixes #1707