fix: string comparison when deleting synced attributes #385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is kind of a fascinating one to me.
Tests were failing on 32-bit devices, on something that didn't seem arch-related to me at least in an obvious way.
The actual bug was really clear: we were doing
if (syncingAppUserID != currentAppUserID) {
where both arguments are strings, so that comparison meant to check for value but was actually checking equality.
The interesting part, though, was that it works for 64 bit devices (we would have caught it straight away in the tests if it didn't).
Turns out, an implementation detail within
NSString
actually makes it work in 64-bit, but not 32-bit.I believe 64-bit devices are internally doing something akin to ruby's symbols where they reuse the same memory address for immutable strings that have the same value, but I couldn't find any docs on it.
Fortunately, the impact of the bug is small - it just means that devices might try to re-sync the same subscriber attribute if it's set to the same value after syncing.
And, although I can't confirm it, from the tests it would seem like it only affects 32-bit devices, which there aren't that many of in the wild.