[Remote Config] Real-time listener stops receiving updates, with no onError, when the stream starts during a persisted backoff

オープン 初心者向け
#8,827 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
android, java
領域
backend

調査の方向性

ConfigRealtimeHttpClient.beginRealtimeHttpStream()と、永続化されたバックオフが有効なときに呼び出される再試行経路を読みます。接続実行中フラグがcanMakeHttpStreamConnection()にどう影響するかを確認し、既存のRemote Configリアルタイムストリームのテストでその経路がカバーされているかを確認します。バックオフ終了後にストリームが再試行し、リスナーが更新を受信できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

api: remoteconfig
[READ] Step 1: Are you in the right place?

Yes, this is a bug in firebase-config in this repository.

[REQUIRED] Step 2: Describe your environment
  • Android Studio version: **Android Studio Quail 4 | 2026.1.4
  • Firebase Component: Remote Config (real-time updates, addOnConfigUpdateListener)
  • Component version: 23.1.0
[REQUIRED] Step 3: Describe the problem

The app stops receiving Remote Config updates for as long as the process lives. Once this happens, a registered ConfigUpdateListener never fires again: values changed in the console never reach the app, and onError is never called, so the app can't detect or recover from it. Only killing the process brings updates back.

On Android a process can stay alive for days, so apps that rely on real-time updates (rather than frequent fetch() calls) keep running on stale config for that whole time. In our app, users stayed on old values for days.

When it happens: two conditions, in this order.

  1. A stream connection fails while the app is in the foreground. This means no network, or the server answering 408, 429, 502, 503 or 504. The SDK then persists a backoff end time in SharedPreferences. The backoff is about 2 minutes after the first failure (randomized ±50%) and doubles with each consecutive failure, up to 256 minutes. It survives process restarts and is cleared only by the next successful (200) connection.
  2. Before that backoff ends, the SDK starts the stream again. It does this whenever the app calls addOnConfigUpdateListener (for example on a cold start) or comes back to the foreground. Both go through startHttpConnection() → beginRealtimeHttpStream(), which hits the backoff early return described below and leaves the stream stuck.

Both are routine. For example, the user opens the app on a flaky connection, switches away, and comes back a minute later. From then on the app receives no updates until the process is killed.

Steps to reproduce:
  1. Register a ConfigUpdateListener with the app in the foreground.
  2. Make the real-time stream connection fail while the app is in the foreground. Keep the app in the foreground until the attempt fails.
  3. Restore network access, kill the app, and relaunch it while the backoff is still in effect. Register the listener again.
  4. After the backoff end time has passed, publish a Remote Config change.

Expected: when the backoff ends, the stream reconnects and the listener receives the update.
Actual: no connection is attempted after the backoff ends, the listener receives nothing, and onError is never called.

Relevant Code:

In ConfigRealtimeHttpClient.beginRealtimeHttpStream(), the method sets isHttpConnectionRunning up front. The early return for an active backoff never clears it, because only the finally block of the connection task clears it:

public void beginRealtimeHttpStream() {
  if (!checkAndSetHttpConnectionFlagIfNotRunning()) { // sets isHttpConnectionRunning = true
    return;
  }

  ConfigSharedPrefsClient.RealtimeBackoffMetadata backoffMetadata =
      sharedPrefsClient.getRealtimeBackoffMetadata();
  Date currentTime = new Date(clock.currentTimeMillis());
  if (currentTime.before(backoffMetadata.getBackoffEndTime())) {
    // No connection was opened, but isHttpConnectionRunning is still true here.
    // The retry below goes through canMakeHttpStreamConnection(), which requires
    // !isHttpConnectionRunning, so it is silently dropped and the stream stays stopped.
    retryHttpConnectionWhenBackoffEnds();
    return;
  }
  // ...
}

Suggested fix: release the flag before scheduling the retry, since no connection was opened on this path:

setIsHttpConnectionRunning(false);
retryHttpConnectionWhenBackoffEnds();
return;
主要言語
Java
スター
2.6k
フォーク
733
平均マージ
2日 15時間
マージ済み PR(30日)
72

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

firebase/firebase-android-sdk のほかの issue

firebase/firebase-android-sdk の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。