🔥 ServerTimestamp isn't working with arrayUnion
Issue
FieldValue serverTimestamp inside arrayUnion isn't working. Outside arrayUnion everything works fine.
await messageRef.update({array: firebase.firestore.FieldValue.arrayUnion({
message,
timestamp: firebase.firestore.FieldValue.serverTimestamp(),
senderId
})
})

Also, on version 5.2.0 same code reproduce this :

Environment
- Platform that you're experiencing the issue on:
- [ ] iOS
- [ ] Android
- [ ] iOS but have not tested behavior on Android
- [x] Android but have not tested behavior on iOS
- [ ] Both
- If known, the version of the platform are you experiencing the issue on:
- API 27
- Operating System:
- [ ] MacOS, version:
N/A - [x] Windows, version:
Windows_NT x64 10.0.17134 - [ ] Other, please specify:
N/A
- [ ] MacOS, version:
- Build Tools:
- Android Studio 3.1.4
React Nativeversion:- 0.57.8
React Native Firebaselibrary version:- 5.1.1
Firebasemodule(s) you're using that has the issue:- [ ] Authentication
- [ ] Analytics
- [x] Cloud Firestore
- [ ] Cloud Messaging (FCM)
- [ ] Crashlytics
- [ ] Dynamic Links
- [ ] Functions Callable
- [ ] Invites
- [ ] Instance ID
- [ ] Notifications
- [ ] Performance Monitoring
- [ ] Realtime Database
- [ ] Remote Config
- [ ] Storage
- Are you using
TypeScript?- [x] No
- [ ] Yes, version:
N/A
- Are you using Expo, e.g.
ExpoKit?- [x] No
- [ ] Yes, I've not ejected
- [ ] Yes, but I have ejected to
ExpoKit - [ ] Yes, but I have ejected to vanilla React Native
- Expo version:
N/A
Hey @manicantic this was resolved in v5.2.0, please could you upgrade, thanks.
Changelog & upgrade guide here: https://rnfirebase.io/docs/v5.x.x/releases/v5.2.0
Hey @Salakar , I tried 5.2.0 and still got an error. If I have update with arrayUnion and serverTimestamp with transaction app instantly crashes ( code : await transaction.update(messageRef, {
array: firebase
.firestore
.FieldValue
.arrayUnion({
message,
timestamp: firebase
.firestore
.FieldValue
.serverTimestamp(),
senderId
})
}) ) ), and if update wihtout transaction I get this error :
Code for this : await messageRef.update({
array: firebase
.firestore
.FieldValue
.arrayUnion({
message,
timestamp: firebase
.firestore
.FieldValue
.serverTimestamp(),
senderId
})
}) .
And first time I updated to 5.2.0 ( while I was writing this issue ) I updated document and firestore looked like this:

Also my app level build.gradle details :
implementation "com.google.firebase:firebase-core:16.0.6"
implementation "com.google.firebase:firebase-auth:16.1.0"
implementation "com.google.firebase:firebase-firestore:17.1.5"
@manicantic hey, sorry I forgot to mention, the fix for v5.2.0 means that data gets passed correctly to Firestore - now that it's correctly passed it will give you that Error as this is the correct behaviour, none of the Firebase SDKs support serverTimestamp in arrayUnion/remove yet. E.g.: https://github.com/firebase/firebase-admin-node/issues/336
References and other values work fine.
@Salakar "none of the Firebase SDKs support serverTimestamp in arrayUnion/remove yet"
"YET", does that mean that it will be supported eventually?
Not supported yet unfortunately!
still not supported yet unfortunately
so is there a workaround? How do I add a server timestamp to an array?
I find it absolutely ridiculous that there is no mention of this in the documentation... what a frustrating afternoon. This issue resulted in app crash with no error msg for me in Flutter. It would take one person half a day to update the docs/SDKs to save thousands of collective hours of wasted time...