Skip to content
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

Checking that the context that is being rest for a disposable context is indeed a disposable context #571

Merged
merged 1 commit into from
Dec 13, 2019

Conversation

rlester
Copy link
Collaborator

@rlester rlester commented Dec 12, 2019

Hey @3lvis I am seeing an odd issue when using a disposable context combined with Sync syncing a background context.

What's happening is I have a disposable context that never has save called on it. It creates a temporary object that is just used to create a request. When that request returns it kicks off Sync which creates a background context.

I have spend a ton of time trying to track it down but for some reason when the background context is saved it causes the newDisposableMainContextWillSave to be triggered even though the observer was never set on the background context. This causes the background context which data I actually want to be stored to be reset and lost.

I also tried to create a unit test to reproduce this with no success. The even stranger part is it doesn't happen every time.

My fix is simple it just checks if the context calling newDisposableMainContextWillSave is really a disposable context. If not don't reset it.

@3lvis 3lvis merged commit cbe6e8f into 3lvis:master Dec 13, 2019
@3lvis
Copy link
Owner

3lvis commented Dec 13, 2019

Good catch @rlester !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants