question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

On iOS, when using setItem on an undefined value, previous items are removed

See original GitHub issue

We found a problem that seems to occur only on iOS. When an undefined value is saved using setItem, previous values saved to keychain are removed. Values added after are saved as they should.

Adding values to keychain

SInfo.setItem('valueThatWillNotAppear', 'thisValueDoesntSave', {});
SInfo.setItem('secondValueThatWillNotAppear', 'thisValueAlsoWontSave', {});
SInfo.setItem('valueThatIsUndefined', undefined, {});
SInfo.setItem('valueThatWillAppear', 'thisValueSaves', {});
SInfo.getAllItems({}).then(values => {
    return values;
});

Resulting keychain values

image

Am I doing something wrong here? I know that I should verify that the value is not undefined but this behavior was definitely not expected.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

14reactions
Kylar13commented, Dec 7, 2018

Holy fucking shit, we just spent 4hours trying to figure out a VERY weird behavior, only to find out that the developer of this fucking library has not even spent the probably 2min that would take to solve this fucking issue. FUCKING FUCK

2reactions
EJohnFcommented, Dec 17, 2018

yea, also spend quite some time what’s happening. Now need to add some surrounded checks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

localStorage returns undefined when page is reloaded
But we need to be sure that localStorage.getItem('todo') actually returns a value, that is why I am pleading for a console.log() on it....
Read more >
Storage.removeItem() - Web APIs - MDN Web Docs
The removeItem() method of the Storage interface, when passed a key name, will remove that key from the given Storage object if it...
Read more >
AsyncStorage - React Native
On iOS, AsyncStorage is backed by native code that stores small values ... Removes an item for a key and invokes a callback...
Read more >
localForage - GitHub Pages
Set a value with localStorage: localStorage.setItem('key' ... localforage.clear() will remove every item in the offline store. Use this method with caution.
Read more >
LocalStorage and SessionStorage | Web Storage APIs
Data can be stored on the client side by using these APIs. ... setItem("key", "value"); //key and value both should be string or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found