lesnitsky / flutter_localstorage

📦 LocalStorage for Flutter
MIT License
299 stars 65 forks source link

FileSystemException: An async operation is currently pending #102

Closed brenomenosso closed 6 months ago

brenomenosso commented 1 year ago

Exception has occurred. FileSystemException (FileSystemException: An async operation is currently pending, path = '/data/user/0/com.app.app')

Method Exception:

Future setKey(String key, dynamic data) async { await _checkIsReady();

if (isReady) {
  await _localStorage!.setItem(key, data);
}

}

brenomenosso commented 1 year ago

@felix-mittermeier help ?

peazz commented 12 months ago

This is a problem for me on too on iOS v16.

Crashalytics is reporting this consistently across many users. I've checked the entire codebase to ensure everything is being awaited properly;

I have tried two ways to initialise too;

storage.ready.then((success) =>AppStorage(storage)

and

await storage.ready AppStorage(storage);

felix-mittermeier commented 12 months ago

Just replace the package inside your pub spec.yaml file with

localstorage:
    git:
      url: https://github.com/Ocell-io/flutter_localstorage.git

And the problem should be fixed :-)

peazz commented 12 months ago

Id suggest this is a system level bug then beyond any packages control 🤷‍♂️

felix-mittermeier commented 12 months ago

Not sure what you mean? The issue is that in real life usage two operations at the same time try to read/write something to the local storage. If this happens, the system error is thrown. So in my fork of the package (as mentioned above) I ensured that it will never try to do two operations simultaneously but after each other.

peazz commented 12 months ago

Well you didn’t state it was a fork at all, you just said replace it with this - not very helpful.

I’ve already migrated to shared preferences.

Good luck.

Sent from Outlook for iOShttps://aka.ms/o0ukef


From: Felix Mittermeier @.> Sent: Friday, October 6, 2023 12:53:01 PM To: lesnitsky/flutter_localstorage @.> Cc: Andy Cresswell @.>; Comment @.> Subject: Re: [lesnitsky/flutter_localstorage] FileSystemException: An async operation is currently pending (Issue #102)

Not sure what you mean? The issue is that in real life usage two operations at the same time try to read/write something to the local storage. If this happens, the system error is thrown. So in my fork of the package (as mentioned above) I ensured that it will never try to do two operations simultaneously but after each other.

— Reply to this email directly, view it on GitHubhttps://github.com/lesnitsky/flutter_localstorage/issues/102#issuecomment-1750512359, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA5SIUNKDFTHEOLVD7QPOWLX57WJ3AVCNFSM6AAAAAA4VLGNNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJQGUYTEMZVHE. You are receiving this because you commented.Message ID: @.***>

felix-mittermeier commented 12 months ago

I mean if it has the same package name, then it's always a fork. But sorry, just wanted to help. This issue was already explained multiple times in this issue: https://github.com/lesnitsky/flutter_localstorage/issues/56#issuecomment-800651187

I was tagged in a comment above, that's why I answered 😅

brenomenosso commented 12 months ago

Thank you @felix-mittermeier, because error:

Error (Xcode): lib/services/localstorage_database.dart:1:8: Error: Error when reading '../../../.pub-cache/git/flutter_localstorage-be405ab1476da74ad4ca58458f93bbc7cddd2c02/lib/localstorage.dart': No such file or directory

pod install e pod update ?

felix-mittermeier commented 12 months ago

@brenomenosso Please provide more details what you did, what happened and what you tried. Otherwise I don't think I can help you

brenomenosso commented 12 months ago

I just added the git part as mentioned above to pubspec.... I tried pod install and pod update, because I'm running and testing on an iPhone

Captura de Tela 2023-10-06 às 11 30 53
felix-mittermeier commented 12 months ago

Normally you don't have to run the pod command newly after changing the package. Did you already try flutter clean and flutter pub get ?

brenomenosso commented 12 months ago

I try, cleaning

brenomenosso commented 12 months ago

not working, import is correct ?

Captura de Tela 2023-10-06 às 11 48 26
felix-mittermeier commented 12 months ago

Yeah that's correct. Hmm this looks like you pub cache is invalid 🤔

Maybe you can try to delete the pubspec.lock file and then run flutter pub get again.

brenomenosso commented 12 months ago

ok, I will do this

brenomenosso commented 12 months ago

not working. By any chance, do you have a print of your pubspec.lock of what it would look like?

lesnitsky commented 6 months ago

v5 is synchronous now.