Firebase is sending me a new refresh token every 200 miliseconds

312 views
Skip to first unread message

Gavin Wright

unread,
Apr 4, 2017, 9:42:50 AM4/4/17
to Firebase Google Group
I'm trying to build my first web app using Firebase for Javascript. I set up my project based off the official documentation and implemented registration with username/password. Then I checked the Network tab in Chrome Developer Tools and noticed that Firebase is sending me a constant stream of refresh tokens, at a rate of about 5 per second. This seems unnecessary and it's slowly but surely eating away at my usage limits. Is this normal behavior or have I done something wrong? Code is in the Pastebin below. Thanks.

Untitled.png

Bassam

unread,
Apr 4, 2017, 5:24:29 PM4/4/17
to Firebase Google Group
Hey Gavin, there is something unusual here.
I just pasted your code and updated the config with another test app. I signed up/signed in and am unable to see these requests.
The token appears to be constantly refreshed in your log. Not sure yet why. Can you explain how this is happening? Does this happen immediately?

Bassam

Gavin Wright

unread,
Apr 5, 2017, 10:28:33 AM4/5/17
to Firebase Google Group
It starts sending them as soon as I get a reference to firebase.database(). If I switch to another tab in the browser it will stop sending them, only to restart as soon as I switch back. 

Here's a link to the actual project I'm building. You should be able to see the token refresh issue for yourself:

Gavin Wright

unread,
Apr 5, 2017, 10:28:34 AM4/5/17
to Firebase Google Group
It starts as soon as I try to get a reference to firebase.database(), assuming I'm signed in. It actually stops sending the tokens if I switch to another tab in the web browser, and then starts up again when I switch back. 

Bassam

unread,
Apr 5, 2017, 1:18:07 PM4/5/17
to Firebase Google Group
Hey Gavin, the problem is js/date.js. I suspect that is messing up the native Date API.
For some reason, we are detecting that the token is expired and trying to refresh it.
If you remove it, the endless refresh will stop. I will try to investigate what this library  https://gavingt.github.io/ClassTask/js/date.js is breaking.

Bassam

unread,
Apr 5, 2017, 1:37:33 PM4/5/17
to Firebase Google Group
It appears to be overriding Date.now()
It is supposed to return the timestamp number 1491413662121. This library overrides it to return the date string "Wed Apr 05 2017 10:34:25 GMT-0700 (PDT)"
The spec is clear:
It should be number of milliseconds since 1970/01/01

Gavin Wright

unread,
Apr 5, 2017, 5:36:04 PM4/5/17
to Firebase Google Group
You're amazing! Thanks. I guess that's what I get for trying to use a library that hasn't been updated in 10 years. :)

Johan Vosloo

unread,
Apr 19, 2017, 10:53:17 AM4/19/17
to Firebase Google Group
Ha! Just spent about 2 hours trying to troubleshoot the same issue... then found this... and yes, date.js was also the culprit!
Now just have to find workarounds for the date.js functions I was using :)
Reply all
Reply to author
Forward
0 new messages