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
[CIS-632] Fix race conditions on database observers #796
[CIS-632] Fix race conditions on database observers #796
Conversation
4cbce9a
to
42d3fbc
Compare
_item.computeValue = { [weak self] in | ||
// Ideally, this should rather be `unowned`, however, `deinit` is not always called on the same thread as this | ||
// callback which can cause a race condition when the object is already being deinited on a different thread. | ||
guard let self = self else { return nil } |
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.
We don't need [weak self]
here, we can get by with [weak frc]
and the guard let fetchedObjects = frc?.fetchedObjects
will take care of it
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.
Correct 👍
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.
Codecov Report
@@ Coverage Diff @@
## main #796 +/- ##
==========================================
+ Coverage 88.62% 88.66% +0.04%
==========================================
Files 219 219
Lines 8570 8576 +6
==========================================
+ Hits 7595 7604 +9
+ Misses 975 972 -3
Continue to review full report at Codecov.
|
We already have a fix like this on other places in the observers. I just extended it to cover the other exposed cases, too.
320a228
to
a6341fb
Compare
We already have a fix like this at other places in the observers. I just extended it to cover the other exposed cases, too.
Fixed exactly as @cardoso suggested