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.

Passing null or undefined as a value to setItem or multiSet doesn't result in an error.

See original GitHub issue

Current behavior

If null or undefined is passed as a value to setItem or multiSet then no error is generated and therefore any listening .catch() methods/catch blocks/error callbacks don’t fire to let you know something went wrong.

Expected behavior

I would expect an error to be generated in the same way as if any other invalid value was passed e.g. number, bool, object.

Repro steps

            try {
              await AsyncStorage.setItem('aTestKey', null, e => {
                console.error(`Error in callback`, { e });
              });
            } catch (e) {
              console.error(`Error in catch`, { e });
            }

Environment

  • Async Storage version: 1.6.2
  • React-Native version: 0.61.4
  • Platform tested: Android
  • Logs/Error that are relevant: N/A

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
leemcmullencommented, Nov 25, 2019

Fantastic, thanks @Krizzu - much appreciated 👍

1reaction
krizzucommented, Nov 25, 2019

@leemcmullen Yes, you’re right - the error is being swallowed for null/undefined in here.

Going to fix that 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to work with React Native Async Storage
In case someone is using AsyncStorage.multiSet([]) , make sure that none of your values is null or undefined . Otherwise, it won't work...
Read more >
API | Async Storage - GitHub Pages
Promise resolving with a string value, if entry exists for given key , or null otherwise. Promise can also be rejected in case...
Read more >
Storage.setItem() - Web APIs - MDN Web Docs
A string containing the value you want to give the key you are creating/updating. Return value. None ( undefined ). Exceptions. setItem() ...
Read more >
A guide to React Native's AsyncStorage - LogRocket Blog
AsyncStorage is an unencrypted and asynchronous data storage system in React Native that allows users to persist data offline.
Read more >
cross-local-storage - npm Package Health Analysis - Snyk
Learn more about cross-local-storage: package health score, popularity, ... If you pass null or undefined, the value will be removed.
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