I am getting a crash report from Sentry saying:
Failed to write manifest file.Error Domain=NSCocoaErrorDomain Code=4 "The folder “manifest.json” doesn’t exist." UserInfo={NSURL=file:///var/mobile/Containers/Data/Application/A7CD2724-A623-49F8-82A5-9B433D1C697F/Documents/RCTAsyncLocalStorage_V1/manifest.json, NSUserStringVariant=Folder, NSUnderlyingError=0x2822e0ae0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
This crash has the highest frequency in my project. ~1.5k a week.
I think the crash occur at this line.
PS: I am using AsyncStorage through react-native-storage, but because the crash occur in AsyncStorage I report it here.
PPS: I think it's weird that the crash log says "The folder “manifest.json” doesn’t exist.", because manifest.json isn't a folder.
Shouldn't crash.
I don't have a way to reproduce yet, but I will keep investigating this issue on my side, and update this thread if I find a way to reproduce.
Any clue to debug this is welcome.
Failed to write manifest file.Error Domain=NSCocoaErrorDomain Code=4 "The folder “manifest.json” doesn’t exist." UserInfo={NSURL=file:///var/mobile/Containers/Data/Application/A7CD2724-A623-49F8-82A5-9B433D1C697F/Documents/RCTAsyncLocalStorage_V1/manifest.json, NSUserStringVariant=Folder, NSUnderlyingError=0x2822e0ae0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Just noticed that sometimes the error look like this
Failed to write manifest file.Error Domain=NSCocoaErrorDomain Code=512 "The file “manifest.json” couldn’t be saved in the folder “RCTAsyncLocalStorage_V1”." UserInfo={NSURL=file:///var/mobile/Containers/Data/Application/840C1A47-3477-42C0-910E-65F6172A3FBA/Documents/RCTAsyncLocalStorage_V1/manifest.json, NSUserStringVariant=Folder, NSUnderlyingError=0x280e4cbd0 {Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument"}}
Hey @StevenMasini,
Any luck getting a repro steps? What AS version are you testing? Does it happen in dev/prod?
I've looked into it a bit and found SO thread that could be related (SO thread). If it's correct, there might be a false-positive result in our migration function.
thanks.
CC @reilem
Hi @Krizzu
Thanks for the fast reply.
This is happening on our PRD version for quite a while, but we only started to take a look at it.
I will try to come up with a reproducible way.
We are still on react-native 0.58.6 and we use the embedded version of AsyncStorage for now.
What is this migration script/function about ? Why do you need to perform migration ?
Thank you for your help 👍
We had an issue where versions < 1.2.2 had used different storage location, so migration from RN's Async Storage to Community's wasn't possible. We fixed naming in next releases + added this migration check for anyone who's been using pre-1.2.2 and upgraded to 1.3+.
Same here with RN 0.59.8.
I'm using @react-native-community/async-storage 1.4.2 to read some session data that aws-amplify writes, but I'm guessing that aws-amplify 1.1.28 (latest version) has not migrated to community version yet.
Getting same error that the one described above.
I am getting the same error as well. I just upgraded from the react-native AsyncStorage.
AsyncStorage error: Error: Failed to write value.Error Domain=NSCocoaErrorDomain Code=4 "The folder “8405d43db8d645a87d3f7b79d26693f9” doesn’t exist." UserInfo={NSURL=file:///var/mobile/Containers/Data/Application/3CCF1D72-BC74-4EC6-B9B5-44D03821C804/Documents/RCTAsyncLocalStorage_V1/8405d43db8d645a87d3f7b79d26693f9, NSUserStringVariant=Folder, NSUnderlyingError=0x281ae7300 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Edit: I will try to provide a reproduction repo next week.
@gluix20 @bell-steven This can be from a situation, where you use the community's Async Storage and one of your dependency still uses old Async Storage.
Meanwhile, it'd be good to have repro steps so we could look into the issue closely
If you come against the same issue, please do reopen.
clean react-native project
react-native - 0.60
react-native-community/async-storage - lastest
the issue reproduces itself after cleaning async-storage content in devtools
This happened to me as well.
I found out that I had _mixed the new and the old AsyncStorage_, so in some files I did
import AsyncStorage from '@react-native-community/async-storage';,
while in others I still had
import {AsyncStorage} from "react-native";.
Not much of a surprise that this isn't working.
Hope this helps!
We're having a log of
Failed to write manifest file.Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “manifest.json” in the folder “RCTAsyncLocalStorage_V1”." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/.../Documents/RCTAsyncLocalStorage_V1/manifest.json, NSUserStringVariant=Folder, NSUnderlyingError=0x281c59440 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
lately ( @Krizzu )
Update react-native-device-info to 4.0.0 in package.json.
Run yarn install
If RN < 0.60:
react-native link react-native-device-info
cd ios
pod install
@doug-stritt I'm not sure we use this dependency... How does it fix async storage?
Related answer: https://stackoverflow.com/a/48814685
Answer text:
Check whether Data Protection is enabled in your iOS app's entitlements. It's probably configured to be NSFileProtectionComplete.
When data protection is enabled like this, all files are encrypted by default. This includes the storage backing React Native's AsyncStorage. This isn't a problem when the application is in the foreground, but, shortly after backgrounding the app or locking the device, iOS will throw away your decryption keys.
If your app attempts to write to a file (such as via AsyncStorage) after its decryption keys have been unloaded, the file operation will fail with precisely the (unhelpful) message that you saw:
Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file ...
An easy fix would be to change your default data protection level to be NSFileProtectionCompleteUntilFirstUserAuthentication. For more information, see "Encryption and Data Protection" in this guide: https://www.apple.com/business/docs/iOS_Security_Guide.pdf
It happened to me, then it disappear after restart
This happens in my project every time I clear AsyncStorage in iOS in the React Native Debugger standalone Mac app. The next time I try to write to async storage, the Failed to write manifest error pops up in the console. I have to kill the app in the simulator to get it to work correctly again. It's difficult to tell if the issue lies with how React Native Debugger clears AsyncStorage or if it's this package itself. My project only uses AsyncStorage from the RNC, not from RN directly.
I have a solution, this happens when you are using AsyncStorage.clear()(which causes the local storage file to be deleted from the device) .. In this case you should use AsyncStorage.removeItem ('key')
I didn't use AsyncStorage directly, I'm using react-native-storage. And didn't using AsyncStorage.clear() at all, still have this error.
I replaced all import AsyncStorage from '@react-native-community/async-storage';
with the import {AsyncStorage} from "react-native"; and I didn't have the issue anymore.
It's weird as the official docs (https://github.com/react-native-community/async-storage) tell you to use the community import statement.
This problem has been addressed in https://github.com/react-native-community/async-storage/commit/36e9a12cd67e2e3ed80a59ae53c266fb5419a490
Here are release note for v1.8.0 having an important note about what has been changed. If you decide to upgrade, please use v1.8.1 and up, as I noticed that some issues where happening while on upgrade (because of missing app directory) and that has been addressed in said 1.8.1.
Great, thank you @Krizzu. I updated the community package with npm update @react-native-community/async-storage and updated all import statements to import AsyncStorage from "@react-native-community/async-storage";
@Krizzu Hi, sorry for not mentioning it sooner, but this issue is not resolved.
Please notice that 36e9a12 cannot really fix this issue as it fixes an issue that causing Failed to parse manifest error while this issue is causing Failed to write manifest file.
@StevenMasini mentioned it when opening the issue that the problem probably got to do to this code.
Do you think you can reopen the issue?
Most helpful comment
clean react-native project
react-native - 0.60
react-native-community/async-storage - lastest
the issue reproduces itself after cleaning async-storage content in devtools