Async-storage: You attempted to set the key `_65` with the value `1` on an object that is meant to be immutable and has been frozen.

Created on 2 Aug 2019  Â·  8Comments  Â·  Source: react-native-async-storage/async-storage

Current behavior

Error being thrown when calling getItem and resolve within function is called.


This started happening randomly and I cannot seem to figure out why. Whenever get item is called this error is being thrown.

You attempted to set the key `_65` with the value `1` on an object that is meant to be immutable and has been frozen.

Expected behavior

I should be expecting it to return a stored item without this error.

Repro steps

I have not figured out how to repro it as I've never had this error before, I don't even know if it is directly related I am just following the logs at this point.

  • Try to call getItem to a large storage item?
  • It seems to be returning debug-local from the requested storage key, which is also debug-local.

Environment

  • Async Storage version: 1.6.1
  • React-Native version: 0.60.4
  • Platform tested: iOS
  • Logs/Error that are relevant:
ExceptionsManager.js:86 You attempted to set the key '_65' with the value '1' on an object that is meant to be immutable and has been frozen.
- <unknown>: AsyncStorage.js:86:10

To get around it I am just doing this:

if (value) {
  resolve(value);
}

As that seems to work for now.

It seems that the value is returning null and is breaking only on this specific call from debug-local haven't seen that before.

All 8 comments

Hey @mikehuebner ,

Yeah, that'd be a taught one to solve without repro steps. Maybe you're trying to save a data that's returned from some kind of third-party API (and that data is indeed frozen?)

@mikehuebner Any update on this?

@Krizzu Apologies on not getting an update sooner, been busy with other projects. But the ending solution ended up being modifying the keys async-storage was saving. I can't remember off the top of my head but it was another package that was trying to save a key within storage that just wasn't correct. Took me a while to figure out which key it was modifying but was easy once I figured that out. If anyone else has a problem similar to this I'll add more on how I fixed it.

For anyone else seeing this error I was also getting it when using this library with redux-persist, and accidentally trying to store a promise in my store.

i was getting this error as well because i was as @CatapultJesse says, storing a promise. All i had to do was put a .then(value => {Asyncstorage.setitem()}) .

I'm getting this with:

 await AsyncStorage.setItem("settings", "{"hasAskedForLocationPermission":true,"hasAskedForNotificationsPermission":true,"hasOptedForNotifications":false}")

Simulator Screen Shot - iPhone 11 Pro - 2020-05-28 at 23 53 46

Hey you see values like _65, it means that you used Promise as value. Try to find if there's a place in code where you forgot to await a value

I figured out the issue. It had nothing to do with async-storage, though. Yes, I hadn't awaited a promise, but it was only a problem when I used it as a property in Segment.trackWithProperties(event, updatedProperties) using expo-analytics-segment. Might be useful for anyone else who gets this problem. I always log before tracking in the console, but it wasn't easy to track down because I don't await tracking to Segment so that it doesn't slow down the app. This was confusing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hms111111 picture hms111111  Â·  24Comments

StevenMasini picture StevenMasini  Â·  22Comments

muhammadn picture muhammadn  Â·  58Comments

sumanthyedoti picture sumanthyedoti  Â·  25Comments

Alaa-Ben picture Alaa-Ben  Â·  20Comments