fix(sortable): unsubscribe item capture when component is destroyed
Hello 👋 As part of our project, we are using Facebook's new Memlab tool to detect memory leaks in SPA applications. While running the tool and analyzing the code of ngx-bootstrap, we saw that your project does a very good job of ensuring that all async operations are cancelled when the component unmounts. However, as per Memlab execution results, we found a dangling subscription that was causing the memory to leak (screenshots below).
[before]
Hence we added the fix by unsubscribing the subscription and you can see the heap size and # of leaks reducing noticeably:

As per the contribution guidelines, we ran the unit test cases; NX successfully ran the target tests for 24 projects. You can analyze this and other potential leak sources, if you like, by running Memlab with a scenario file covering the maximum # of use cases. Following is a sample of the scenario file we used (it needs to be a .js file but attaching here in .txt form): ngx-test-scenario-memlab.txt
Note that some other reported leaks (in Memlab) originated from Storybook, hence were ignored.
Codecov Report
Attention: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.
Project coverage is 76.59%. Comparing base (
e77c928) to head (b98712f). Report is 1 commits behind head on development.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/sortable/sortable.component.ts | 42.85% | 4 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## development #6546 +/- ##
===============================================
- Coverage 76.60% 76.59% -0.01%
===============================================
Files 317 317
Lines 10748 10754 +6
Branches 2866 2866
===============================================
+ Hits 8233 8237 +4
- Misses 2514 2516 +2
Partials 1 1
| Files with missing lines | Coverage Δ | |
|---|---|---|
| src/sortable/sortable.component.ts | 8.24% <42.85%> (+1.65%) |
:arrow_up: |
... and 5 files with indirect coverage changes
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update b56863d...b98712f. Read the comment docs.
35 failed tests on run #3851 ↗︎
Details:
| Merge 0375b49d6ae355317216020e3642123e7579f227 into 663c70e688dfbc0215683c76cc25... | |||
| Project: ngx-bootstrap | Commit: 4329b38ec4 ℹ️ |
||
| Status: Failed | Duration: 36:47 💡 | ||
| Started: Jan 27, 2023 9:22 PM | Ended: Jan 27, 2023 9:59 PM | ||
datepicker/locales_spec.ts • 2 failed tests • full
typeahead_page_spec.ts • 1 failed test • full
| Test | ||
|---|---|---|
| Typeahead demo page testing suite > On blur > clicking anywhere outside auto-fills "Option on blur" with the first option from the matches list |
Screenshot
|
|
modals_service_page_spec.ts • 13 failed tests • full
popover_page_spec.ts • 1 failed test • full
| Test | ||
|---|---|---|
| Popover demo page testing suite > Component level styling > when user clicks on "I have component level styling", then popover-container appear above the button |
Screenshot
|
|
tabs_page_spec.ts • 1 failed test • full
| Test | ||
|---|---|---|
| Tabs demo page spec > Dynamic tabs > when user clicks on close icon near tab, then this tab removed |
Screenshot
|
|
The first 5 failed specs are shown, see all 13 specs in Cypress Cloud.
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.
bump @valorkin
@lexasq Does this PR need any update on my part? :)
@Arooba-git thanks for your contribution, this PR definitely caught my eye to have a better look. No actions needed on your part, we appreciate your help to make this lib better!