-
Notifications
You must be signed in to change notification settings - Fork 162
Fix issue in ShareReplay publisher Switch to removing subscriptions after completion is sent #109
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
Conversation
@jasdev I know you reviewed the previous PR, would you be able to take a look at this? |
Codecov Report
@@ Coverage Diff @@
## main #109 +/- ##
==========================================
- Coverage 97.23% 97.12% -0.11%
==========================================
Files 62 62
Lines 3323 3340 +17
==========================================
+ Hits 3231 3244 +13
- Misses 92 96 +4
Continue to review full report at Codecov.
|
Seems reasonable to me after a quick check — any chance we can add a test to make sure this doesn’t accidentally regress down the line? 🙏🏽 |
Yeah absolutely. I'll try and write a failing test for the issue we experienced |
f250f4b
to
e413147
Compare
|
||
lock.lock() | ||
defer { self.lock.unlock() } | ||
self.subscriptions.removeAll() |
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.
so the point of this is to remove all of the subscriptions upon completion?
Hello @jabeattie |
I've created #124 |
Closed in favor of the now-merged #124. Thank you! |
Hey folks, you may remember my previous PR: #86
In this I tried to fix a memory leak that we'd identified, however, it seems like this solution caused a different problem that we've only uncovered when updating to 1.5.0.
I'm not 100% of what in our usage caused the issue - it is weirdly only presented in tests -but I've checked that this change both allows the tests in our consuming app to pass and works when the app is running for users.
I've removed the call to
cancel()
and instead clear the subscriptions after they are forwarded a completion. This seems to make sense to me logically, as once a subscriber has received a completion it can't do anything else.I appreciate however that this is a change that had a problem for a new unknown change. If you aren't sure about this, I can instead revert my original PR. This would bring back the memory leak, but avoid the failing scenario we are seeing