Fix Memory Leak in SearchJournalEntryComponent , Added OnDestroy + takeUntil Cleanup
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 OnDestroy lifecycle hook was implemented along with an RxJS Subject and the takeUntil pattern. 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!
-
[x] If you have multiple commits please combine them into one commit by squashing them.
-
[x] Read and understood the contribution guidelines at
web-app/.github/CONTRIBUTING.md.
Summary by CodeRabbit
- Bug Fixes
- Enhanced resource cleanup in the journal entry search component to improve stability and prevent potential memory-related issues when navigating or interacting with the search interface.
[!NOTE]
.coderabbit.yamlhas unrecognized propertiesCodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'pre_merge_checks'⚙️ Configuration instructions
- Please see the configuration documentation for more information.
- You can also validate your configuration using the online YAML validator.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 74054e62-babd-4c87-95a1-669e6e04fd49
📥 Commits
Reviewing files that changed from the base of the PR and between ad493a157ba33c83b7339f3c8d93c64608ae0158 and 2f96467687fab6cd3b35d0b070f4ba96dd2d310d.
📒 Files selected for processing (1)
src/app/accounting/search-journal-entry/search-journal-entry.component.ts
Walkthrough
The SearchJournalEntryComponent now implements the OnDestroy lifecycle hook with a destroy$ Subject to ensure all RxJS subscriptions are properly cleaned up when the component is destroyed, preventing potential memory leaks.
Changes
| 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
- openMF/web-app#3065: Implements the same OnDestroy pattern with destroy$ Subject and takeUntil(this.destroy$) to prevent memory leaks across Angular components.
- openMF/web-app#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.
LGTM
@IOhacker can you please merge this pr then