Since the time shift at the 29th of October 2017 I'm running in some really strange behaviours while developing with the firebase products.
I'm developing a hybrid app with Ionic (3). While I'm developing and testing in the browser (mobile emulated device) everything works fine. As soon as I switch to my real device (Samsung Galaxy S7, no root, modded or something else), all writes to the database with a timestamp are failing.
In my code I create a timestamp like this: Date.now()
In my firebase rules I validate timestamps usualy like this:
"timestamp": {
".validate": "newData.isNumber() && newData.val() <= now"
}
For me this rule means, that the new data, which wants to be written into the database, must be a number and the value of the new data must be less than or equal to the current server timestamp. If one of these conditions doesn't match, it will throw a warning at the client.
I've spent a whole day debugging my code and finding the bug. When I remove (comment out) the .validate key on the timestamp related rules, everything works fine.
So I played a little bit with the timestamp values in the firebase rules. For example I added a little buffer to the server timestamp like: (now + 10000) (10secs).
Suddenly it worked. I decreased the value until it stopped working on my real device. I stopped at (now + 5000) (5secs).
So now my question is, why this behavior is the way it is.
Before the time shift, everything worked fine. In my understanding it couldn't be possible that a client timestamp is ahead of the server timestamps. (except the local time on the real device was modified by the user itself).
Looking for some help, the workaround with the additional 5 secs seems a bit dirty.
Cheers Unkn0wn0x
BTW: Each time I modified the firebase rules and deployed them to the server(s), I've waited for about five minutes.