Giter VIP home page Giter VIP logo

Comments (4)

alessandro-bottamedi avatar alessandro-bottamedi commented on May 28, 2024

Yes the problem is that, unlike RNFS, Expo Fs does not expose the 'appendFile' method. So, for every log, i need to read the contents of the file and write it in full, this obviously causes the problem you described.

There are two ways to fix it:

  1. make the procedure synchronous (but this would cause a lot of performance problems)

  2. Rewrite the module to work with a queue, string all write requests, and execute them one at a time.

This last option, however, requires a lot of work, I hope they will soon add to expo fs a potion to add lines to a file ...

in the coming weeks I will consider what to do.

from react-native-logs.

chmac avatar chmac commented on May 28, 2024

@alessandro-bottamedi Yeah, it's a tough one.

I looked a little into RNFS and they have this "append to file" implemented in native code. What about we open a feature request with Expo to add this option? Seems like the code already exists from RNFS so perhaps it's not so much work for Expo to add this option.

Otherwise, I also considered the queue option, and that seems like it adds a lot of complexity. I considered adding it in our logs, because then I could also delay sending logs until we'd initialised our logging settings. That would let me store log levels on the filesystem in the phone for example. But, it's complicated and has the potential to introduce horrible, hard to trace bugs.

One thing to note, I've used a few async / Promise queues, and there are some battle tested libraries out there. Maybe using an existing queue library would be achievable without introducing so much extra code into this package, but adding extra dependencies (which bring their own complications of course).

Anyway, thanks for the considered response. I'll be curious to hear what you think makes sense here.

from react-native-logs.

Kirysha avatar Kirysha commented on May 28, 2024

@chmac @alessandro-bottamedi Hello, please tell me how you solved this problem

from react-native-logs.

alessandro-bottamedi avatar alessandro-bottamedi commented on May 28, 2024

@chmac With v 3.0.4 i think I was able to create a custom queue for the ExpoFS module to avoid race conditions issues. I could not use existing queue management packages since they all make use of a DB (sql or realm) and are not compatible with expo.
Please try it and let me know if there are any problems.

from react-native-logs.

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.