Code Monkey home page Code Monkey logo

Comments (3)

ciceromsjr avatar ciceromsjr commented on August 22, 2024

UPDATE:

In my application, I had disabled Firestore persistence. I tested re-enabling it, and the error did not occur anymore. It worked!

From this

FirebaseFirestore.instance.settings = const Settings(persistenceEnabled: false);

To this

FirebaseFirestore.instance.settings = const Settings(persistenceEnabled: true);

from flutterfire.

encoder90 avatar encoder90 commented on August 22, 2024

I have changed FirebaseFirestore.instance.settings = const Settings(persistenceEnabled: true); but the problem still exists. If I remove firebase folders from %LOCALAPPDATA% the app runs for a single time. but the problem still exists.

from flutterfire.

ciceromsjr avatar ciceromsjr commented on August 22, 2024

Hi @encoder90

Yes, you are correct. I celebrated too soon...

For some reason, using Firestore persistence, after the first access, the LDB and/or CURRENT files get corrupted. This only happens on some machines and I couldn't identify a pattern among them.

So, what I did to solve it was to clear the persistence as soon as Firebase is initialized, even before opening any screen in the app.

It looks like this:

void main() async {
WidgetsFlutterBinding.ensureInitialized();

await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);

FirebaseFirestore.instance.settings = Settings(
// Curiously, it is necessary to enable persistence to avoid a crash where the database of
// this cache is not found. However, it is necessary to clear this same cache to avoid the crash due to it being corrupted.
// #12987
persistenceEnabled: Platform.isWindows,
);

// Curiously, it is necessary to enable persistence to avoid a crash where the database of
// this cache is not found. However, it is necessary to clear this same cache
// to avoid the crash due to it being corrupted.
if (Platform.isWindows) {
await FirestoreMF.instance.clearPersistence();
}

I do this only on Windows, as I haven't tested it on other platforms. In any case, it worked in the tests I did.

from flutterfire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.