FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
130 stars 26 forks source link

Losing connection to firebase firestore when app is dormant/background even if still logged in #4610

Closed sanjayelate closed 2 days ago

sanjayelate commented 4 weeks ago

Can we access your project?

Current Behavior

When the app has been dormant and then is opened again my app loses its connection to Firebase/Firestore, even though the user is still logged in so you need to log the user out and back in to restore functionality

These errors appear in the logs: 11.2.0 - [FirebaseFirestore][I-FST000001] WatchStream (6480310701) Stream error: 'Unknown: An internal error has occurred, print and inspect the error details for more information.'

flutter: Cloud call error! Code: 17999 Details: null Message: An internal error has occurred, print and inspect the error details for more information.

Expected Behavior

If user hasn't logged out, opening the app again should continue ability to work normally

Steps to Reproduce

Put app into background for a while then open it back up again and try something that requires updating or retrieving data from firestore

Reproducible from Blank

Bug Report Code (Required)

ITFfk8n1z892pbwC+a6JLMJKiSkXNW0cTIMziNZ+exUbfaL1Bu0ifcnRNlVBQt+7aVNcCk6IrDkdp87OiNr9GvE5IReWGZs7/5dcbz3Oe2imVL6kBqW7dXJCBeZTGB2m5Kek2R5COsZpSGMuw1OyN+mRVjLDFOu/Zwh9f6PHaOI=

Visual documentation

Screenshot 2024-10-24 at 20 18 18

Environment

- FlutterFlow version:  v5.0.8
- Platform: iOS and Android

Additional Information

No response

Alezanello commented 3 weeks ago

Hello,

I apologize for the late response. Does this issue still persist, or was it fixed in the latest FlutterFlow updates?

sanjayelate commented 3 weeks ago

Hello,I apologize for the late response. Does this issue still persist, or was it fixed in the latest FlutterFlow updates?

Still persists

sanjayelate commented 3 weeks ago

I've also tried this custom action to reconnect but it didn't work:

import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart' as firebase_auth; import 'package:logging/logging.dart';

final _logger = Logger('FirestoreConnectionCheck');

Future checkAndRestoreFirestoreConnection() async { try { bool isConnected = await _checkFirestoreConnection();

if (isConnected) {
  return true; // Connection is active, no need to log
}

firebase_auth.User? currentUser =
    firebase_auth.FirebaseAuth.instance.currentUser;

if (currentUser != null) {
  await FirebaseFirestore.instance.enableNetwork();
  _logger
      .info('Firestore connection restored for user: ${currentUser.uid}');
  return true;
} else {
  _logger.warning(
      'Firestore connection lost. User not logged in, unable to restore.');
  return false;
}

} catch (e) { _logger.severe('Error checking/restoring Firestore connection', e); return false; } }

Future _checkFirestoreConnection() async { try { await FirebaseFirestore.instance .runTransaction((transaction) async => null) .timeout(Duration(seconds: 5)); return true; } catch (e) { // Only log if the connection check fails _logger.warning('Firestore connection check failed', e); return false; } }

kamiloxl commented 3 weeks ago

I have the same issue. In crashalitycs i see Fatal Exception: java.lang.RuntimeException Internal error in Cloud Firestore (25.1.0)

sanjayelate commented 2 weeks ago

Any update to this?

Alezanello commented 2 weeks ago

Hello everyone,

First, I want to apologize for the delay in responding.

I was unable to reproduce this issue in a blank project; however, I was able to replicate it within your specific project. This leads me to believe it may be a project-specific issue. In this case, our support team would be the best resource to help resolve it. Please feel free to reach out to them via email at support@flutterflow.io or by using the in-app chat feature within FlutterFlow.

I will be closing this issue for now, as this tracker is specifically for bugs that can be reproduced in blank projects.

If you are able to replicate the issue in a blank project, please let us know and provide the bug code associated with that project.

Thank you so much for your understanding!

github-actions[bot] commented 6 days ago

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue.

Alezanello commented 2 days ago

Closing this issue since we haven't heard back from you. If you are still facing the problem please submit a new issue. Have a great day!