Closed
Description
Operating System
macOS Sonoma 14.6.1
Environment (if applicable)
Chrome 130
Firebase SDK Version
11.2.0
Firebase SDK Product(s)
Database
Project Tooling
Javascript + React + Webpack
Detailed Problem Description
Realtime should quickly reconnect after connection lost.
But there is a bug in Firebase JS SDK that leads to delays before reconnect attempt that exceeds max constant values.
Steps and code to reproduce issue
Steps
- Be online
- Open application that uses Realtime DB
- Change client computer clock (decrease time by 15 minutes, for example set 14:30 instead of 14:45)
- Turn off wifi
You will see that Realtime DB may try to reconnect in 3 minutes even for Admin accounts (for Admin accounts constant maximum is 30 seconds).
The bug is in this code:
firebase-js-sdk/packages/database/src/core/PersistentConnection.ts
Lines 800 to 815 in b12af44
So timeSinceLastConnectAttempt
may become negative, and so lead to significant exceeding of max delays defined in constants.