RCTAsyncLocalStorage no longer working after upgrading to SDK 44

In the previous release of the app (SDK Version 37), our app was using RCTAsyncLocalStorage to save jpg’s imported from a network camera to device local storage.

Every time we import an image from the network camera, we check the RCTAsyncLocalStorage manifest.json for a unique image hash that we generate and store for each jpg, so we can avoid importing duplicate images.

However, after upgrading to Expo SDK 44, RCTAsyncLocalStorage no longer seems to be working the way it did previously. (This is on iOS native side. Issue is also present on Android, but haven’t started there yet)

Our AsyncStorage module looks like this:

import Foundation

class AsyncStorage {

    let storageLocation = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("RCTAsyncLocalStorage")

    func fetchManifest() -> [String: Any]? {
        do {
            let manifestLocation = storageLocation.appendingPathComponent("manifest.json")
            let manifestString = try String(contentsOf: manifestLocation)
            let manifestData = manifestString.data(using: .utf8)!
            let manifestJSON =  try JSONSerialization.jsonObject(with: manifestData, options: .allowFragments)
            return manifestJSON as? [String: Any]
        } catch {
            print(error)
            return nil
        }
    }

    func fetch(cacheKey: String) -> Any? {
        var result: String?
        let m = fetchManifest();
        if let value = m?[cacheKey] {
            if let s = value as? String {
                result = s;
            }
            else {
                result = nil;
            }
        } else {
            result = nil;
        }
        return result;
    }
}

While testing, I noticed image uniqueness was no longer being determined correctly, so I began sifting through logs to determine the cause of the issue. I found that when we invoke fetchManifest(), we are getting nothing back, and the logs show this:

2022-01-31 18:13:19.415872-0500 ios[1387:429190] Image date: 2022-01-31 20:02:00 +0000

2022-01-31 18:13:19.416000-0500 ios[1387:429190] Image hashValue: -5223589484288181148

2022-01-31 18:13:19.416443-0500 ios[1387:429190] Image timeDictionary entry: Optional(2022-01-31 20:02:00 +0000)

Error Domain=NSCocoaErrorDomain Code=260 “The file “manifest.json” couldn’t be opened because there is no such file.” UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/40E2F67B-547E-4B77-A124-5DB2EEB42476/Documents/RCTAsyncLocalStorage/manifest.json, NSUnderlyingError=0x280bfc0f0 {Error Domain=NSPOSIXErrorDomain Code=2 “No such file or directory”}}

2022-01-31 18:13:19.419254-0500 ios[1387:429190] Image exists in async storage: nil

Any information would be much appreciated, as I’m finding any official documentation difficult to come by. Thanks in advance!