hamburger-tech-nits

主にプログラミングのNITSな話

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError [firebase_remote_config/internal] internal remote config fetch error

FlutterでRemote Configを利用していたところ、Crashlyticsにエラーログが上がるようになった。

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError
[firebase_remote_config/internal] internal remote config fetch error

元のコード

// Wrapperクラスに処理をまとめていた
classs RemoteConfigModel {

  Future<void> init() async {
    final remoteConfigInstance = FirebaseRemoteConfig.instance;
    final activated = await remoteConfigInstance.fetchAndActivate();
    // 後続処理
  }
}

関連していそうなissue

github.com

Not sure how this would help but somehow adding the delay there fixes the issue

github.com

That is also why I tried the delay in the first place, looks like a timing issue to me

インスタンス生成直後にActivateするとタイミングの問題で処理に失敗するのかも、という仮説。

コメントにある通り、Delayで遅延をかけることで状況が改善した。

  await Future.delayed(const Duration(milliseconds: 500)).then((_) async {
    await remoteConfigInstance.fetchAndActivate();
    // 後続処理
  }