-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Blaze: Update blaze instance from the correct thread #20413
Conversation
Generated by 🚫 dangerJS |
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
|
|
||
guard let blog = context.object(with: objectID) as? Blog else { | ||
DDLogError("Unable to update isBlazeApproved value for blog") | ||
completion?() |
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.
The completion block can't be called here, otherwise it'll cause the same issue in #20196.
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.
An alternative would be declaring contextManager as CoreDataStackSwift
, so that you can catch the error thrown by the Core Data operation closure:
contextManager.performAndSave({ context in
let blog = try context.existingObject(with: objectID) as! Blog
blog.isBlazeApproved = isBlazeApproved
}, completion: { (result: Result<Void, Error>) in
completion?()
}, on: .main)
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.
The completion block can't be called here
Fixed! 20eddd8
We're only logging the error, so I decided to use guard let blog = try? ...
blog.isBlazeApproved = isBlazeApproved | ||
DDLogInfo("Successfully updated isBlazeApproved value for blog: \(isBlazeApproved)") | ||
|
||
}, completion: { | ||
completion?() |
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.
This completion
block will be called regardless if the Core Data operation in the closure above success or not.
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.
That's the desired behavior - I've amended the documentation to clarify this 🙇♀️
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.
The changes look good to me, and it works as described 🚀
Taking over merge to ship a new beta |
Thank you for the fix @momo-ozawa ! Can you add a link to a convo with context about going with a beta fix instead, for example, of a hotfix? Thanks! |
@hypest 👋 We didn't have a conversation about whether to do a betafix vs hotfix for this crash. Sorry - I should have checked in with the release rotation team! Since this crash affected ~0.05% of users (low impact), and this isn't a critical flow (medium severity), I figured this would be a betafix instead of a hotfix. Sentry Issue: JETPACK-IOS-Z5 |
Thanks for elaborating @momo-ozawa !
Makes sense. To try to understand the impact, I wonder, are the users affected all on the Blaze flow, or some may be on an irrelevant flow? If all on the Blaze flow, would all Blaze flow users encounter the issue? I would elevate the impact assessment depending on those questions. For the severity assessment part, I wonder if the issue has been a blocker for the Blaze users for, say, reaching the check-out stage. If yes, I'd elevate the severity here as well. I understand that the fix will be out with the 22.0 release scheduled for today so, no further action needed, but I think we probably want to update the crash priority matrix, to include the new revenue flows, the least. |
@hypest Those are good points, thanks for sharing.
This crash can happen when assessing whether users are eligible for Blaze. So this is before users begin the blaze purchase flow. Also, it doesn't happen all the time.
Agreed! I've updated the crash priority matrix to include this info. pbArwn-1gZ-p2 |
Fixes #20397
Description
Fixes an issue where Blog managed object was being updated from the wrong thread.
Queries the Blog managed object using the context provided by the
performAndSave
closure to ensure the managed object is updated correctly.Ref: pbArwn-602-p2
How to test
-com.apple.CoreData.ConcurrencyDebug 1
to your launch argumentsRegression Notes
Potential unintended areas of impact
n/a
What I did to test those areas of impact (or what existing automated tests I relied on)
n/a
What automated tests I added (or what prevented me from doing so)
n/a
PR submission checklist:
RELEASE-NOTES.txt
if necessary.