-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛] read once return cached value and not realtime value #8070
Comments
Hi there! thanks for the reproduction function - I assume since the API for cache size is only available on database that it is the database module? The reproduction is not complete so I'm unsure but that's my best guess What versions are you on currently? |
Yes this is our Firebase component that manage all related to firebase. I'm on react-native 0.73.9 and iOS 17 and 18, but on Android too, real device or simulator is the same. "@react-native-firebase/analytics": "^20.1.0", |
Thanks for the extra information - I won't be looking into this personally but that will help others I can say that this sounds like it will be pretty difficult to reproduce since it appears that it takes several days for the problem to show up? I wonder if a workaround might be in order then, along the lines of maybe https://rnfirebase.io/reference/database/query#keepSynced or similar? alternatively, on a periodic basis you could perhaps do a goOffline/goOnline sequence to see if that affects things, or a setPersistenceEnabled false/true cycle, or a setPersistenceCacheSizeBytes to zero then your desired size If it were me, I'd have a screen only enabled for testers / debug and I would add buttons that allowed me to try those things, then go back and try to fetch the values you suspect are cached, to see if any of those ideas have an affect even and allow fetch of current values I don't know if any of that will actually help, but perhaps it will, and allow you to self-help / unblock on this one |
i've try something like this: // Lettura semplice senza listener
/**
* Lettura secca del path passato in input
* @param {*} submitFunction
* @returns
*/
async function simpleDatabaseRead(path, isArray){
const pathRef = dbRef.ref(path);
pathRef.keepSynced(true);
return dbRef
.ref(path)
.once('value').then(snapshot => {
try {
if(isArray){
let val = snapshot.val();
//console.log(val)
let list = Object.keys(val).map(k =>{ return {...val[k], key: k}});
return list
} else {
//console.log("----------" + isArray)
return snapshot.val()
}
} catch (error) {
return null;
} finally {
pathRef.keepSynced(false);
}
});
} but seems not affect. can you recommend me something better? |
You mentioned this takes a few days to reproduce? Surprised you can already reproduce it - or you mean you added these lines of code just now and you are still getting cached values because you did not uninstall/reinstall 🤔 These are just guesses on my part, so I'm not sure how they would actually work, but it may be that once they are out of sync it is too late for the
Sorry, I've already posted up all the ideas I had |
Yes i've add that code on my app and release an update. I got cached value and not updated value. |
hey, I think I am having a similar issue and it comes down to the fact that once it's connected, it doesnt try to reconnect. |
Issue
I've created this function. The function works like i expect when i install my app but after few days i can't get current realtime value of database but seems that use cached value. Uninstall the app and reinstall fix the issue.
Project Files
Javascript
package.json
:# N/A
firebase.json
for react-native-firebase v6:iOS
Click To Expand
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:<!-- N/A -->
Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:e.g. 5.4.3
Firebase
module(s) you're using that has the issue:e.g. Instance ID
TypeScript
?Y/N
&VERSION
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: