Repository navigation
Description
[REQUIRED] Please fill in the following fields:
- Pre-built SDK from the website or open-source from this repo: open-source from this repo
- Firebase C++ SDK version: 14.2.0, and
mainis the same - Problematic Firebase Component: Database (desktop)
- Other Firebase Components in use: Auth, Firestore, Functions, Storage, App Check
- Platform you are using the C++ SDK on: Linux (x86-64)
- Platform you are targeting: desktop
[REQUIRED] Please describe the issue here:
database/src/desktop/connection/persistent_connection.cc:
scheduler_->Schedule(new callback::CallbackValue2<ThisRef, bool>(
safe_this_, force_refresh, [](ThisRef ref, bool force_refresh) {
...
// TODO(chkuang): Implement Exponential Backoff Retry
connection->connection_state_ = kGettingToken;TryScheduleReconnect() schedules the next attempt with no delay. Every failure comes back to it: OnDisconnect(), and HandleTokenFutures() when the Auth token future fails. So a connection that can't be made is retried as fast as the scheduler runs. The writes waiting on it don't fail, so it goes on until the app quits.
Two ways to get there:
- The server can't be reached. 57,572
connect()calls in 10 seconds. - The signed-in user's refresh token is refused.
GetTokenAsyncfails, the connection never opens, and every attempt sends a refresh request. 68,127 of them in 30 seconds.
The second one is easy to hit on desktop. The session is restored from the keyring, and if the server refuses its refresh token with INVALID_REFRESH_TOKEN, Auth keeps the user. SignOutIfUserNoLongerValid() only signs out on USER_NOT_FOUND, TOKEN_EXPIRED and USER_DISABLED.
The InterruptInternal() TODOs show where the retry helper was meant to go. What I'm carrying is the Android SDK's RetryHelper behavior: 1s, times 1.3 up to 30s, jittered. No wait after a connection that stayed up 30s or after a resume. Interrupt cancels the waiting attempt. The same two cases drop to 14 connects in 10s and 12 refresh requests in 30s. The patch is about 70 lines in persistent_connection.{h,cc}, happy to send a PR.
Steps to reproduce:
Have you been able to reproduce this issue with just the Firebase C++ quickstarts ?
Not tried. Any app with a Database and no server to reach should do it.
What's the issue repro rate? (eg 100%, 1/5 etc)
100%.
What happened? How can we make the problem occur?
Server out of reach:
- Point the Database at a port nothing listens on.
SetValue()on any path.- One core spins,
strace -e connectshows thousands of attempts a second.
Refresh token refused, against the emulator suite:
- Sign in anonymously against the Auth emulator and quit. The session stays in the keyring.
- Restart the emulators so the user is gone. Wait an hour, or move the clock, so the ID token has expired.
- Start again, let the session restore, and
SetValue(). - The write never completes, and the Auth emulator gets a refresh request on every attempt.
Relevant Code:
firebase::App* app = firebase::App::Create(options);
auto* db = firebase::database::Database::GetInstance(
app, "http://127.0.0.1:9001"); // nothing listening
db->GetReference("probe/x").SetValue(1);
// never completes; connect() in a tight loop
Activity
dconeybe commentedon Nov 20, 2026
I'm actually working on this at the moment. @AustinBenoit once I get contributor access to this repo, feel free to assign it to me.
dconeybe commentedon Nov 26, 2026
Fix has been submitted: #1983
The fix will be included in the next release of the firebase-cpp-sdk, which is planned for mid-December 2026.
I'm going to close this issue since there is no more work from our side. If there are issues with the fix then please open a new issue and provide a link back to this one.