Fix Memory Leak in SearchJournalEntryComponent , Added OnDestroy + takeUntil Cleanup#3550
Fix Memory Leak in SearchJournalEntryComponent , Added OnDestroy + takeUntil Cleanup#3550Manishnemade12 wants to merge 1 commit intoopenMF:devfrom
Conversation
…n search journal entry component subscriptions
|
Note
|
| Cohort / File(s) | Summary |
|---|---|
Memory Leak Prevention src/app/accounting/search-journal-entry/search-journal-entry.component.ts |
Implements OnDestroy lifecycle hook and adds a destroy$ Subject. All existing subscriptions (valueChanges, sort.sortChange, merged sort/paginator stream) updated to use takeUntil(this.destroy$) operator for proper cleanup on component destruction. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
- WEB-643 fix(clients): add takeUntil pattern to prevent memory leaks i… #3065: Implements the same OnDestroy pattern with destroy$ Subject and takeUntil(this.destroy$) to prevent memory leaks across Angular components.
- WEB-(399)-fix(webappcomponent): prevent memory leaks by adding RxJS cleanup and… #2757: Applies the identical subscription cleanup pattern using destroy$ Subject and takeUntil to manage RxJS subscription lifecycle.
Suggested reviewers
- alberto-art3ch
- IOhacker
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly identifies the main change: fixing a memory leak by implementing OnDestroy and takeUntil in SearchJournalEntryComponent. It directly matches the changeset's core objective. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment @coderabbitai help to get the list of available commands and usage tips.
Description
This PR resolves a significant memory leak and potential performance degradation in the
SearchJournalEntryComponent. Previously, the component accumulated multiple live RxJS subscriptions (for form value changes, sorting, and pagination) every time a user visited the page, because it lacked proper teardown logic when the component was destroyed.To fix this, the standard Angular
OnDestroylifecycle hook was implemented along with an RxJSSubjectand thetakeUntilpattern. This ensures that all active subscriptions are automatically cleaned up when the component unmounts, preventing stale callbacks from executing and freeing up memory efficiently.No new external dependencies are required for this change.
Screenshots, if any
(Please add memory profiler heap snapshots showing Before/After if required by the reviewers.)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
If you have multiple commits please combine them into one commit by squashing them.
Read and understood the contribution guidelines at
web-app/.github/CONTRIBUTING.md.Summary by CodeRabbit