Skip to content
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

Fix negative offset of reconnect delay (#8718) #8719

Merged
merged 3 commits into from
Jan 29, 2025

Conversation

alexander-at-t
Copy link
Contributor

Fix for #8718

Copy link

changeset-bot bot commented Jan 23, 2025

🦋 Changeset detected

Latest commit: c06bdd7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/database Patch
firebase Patch
@firebase/database-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

google-cla bot commented Jan 23, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@DellaBitta DellaBitta requested review from a team as code owners January 27, 2025 15:35
@DellaBitta
Copy link
Contributor

HI @alexander-at-t,

Thanks for the contribution! You'll need to sign the Google CLA before we can merge this PR. Thanks!

@alexander-at-t
Copy link
Contributor Author

Hi @DellaBitta ,

Thanks for the contribution! You'll need to sign the Google CLA before we can merge this PR. Thanks!

Thank you for checking it!
I did sign before your message. Looks like you use old CLA check link. Please check latest status of CLA.

See confirmation on screenshot and also these links:

Screenshot 2025-01-28 at 11 14 58 AM

Copy link
Contributor

@maneesht maneesht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maneesht
Copy link
Contributor

Thanks for this change. @alexander-at-t what use-case is this for? I understand it's if the clock goes back, is this in the situation when a user might be changing time zones?

@alexander-at-t
Copy link
Contributor Author

Thanks for this change. @alexander-at-t what use-case is this for? I understand it's if the clock goes back, is this in the situation when a user might be changing time zones?

@maneesht We found an issue by report from our users. Then we found these log records in Realtime DB logs:

2025-01-23T07:15:57.317Z p:0: Trying to reconnect in 609303.1190405517ms 
...
2025-01-23T07:56:03.534Z event: /.info/serverTimeOffset:value:312809 

"reconnect in 609303.1190405517ms" is not expected, taking into account max reconnect constants.

And it doesn't look like changing time zones, because it should not affect serverTimeOffset and offset would be multiple of 30/60 minutes.

We don't know exact steps how it was reproduced by our users. Is it possible that their laptop drained battery, and so clocks become unsynchronized? I don't have other ideas of these 5-10 minutes differences. Or maybe there is a bug in serverTimeOffset calculation by Realtime DB in some edge cases?

The fix is important even if we don't know how to reproduce the bug, because autoreconnecting Realtime DB with 10 minutes delay breaks our app's users experience. We use Realtime DB for tracking users online status.

@DellaBitta DellaBitta merged commit 01f36ea into firebase:main Jan 29, 2025
32 of 34 checks passed
@maneesht
Copy link
Contributor

@alexander-at-t there's still a chance that the user changed time zones and the delay ends up being 10 minutes, as we multiply the reconnectDelay by Math.random(), which could incidentally return a fraction that, when multiplied by 60 minutes, could give 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants