Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FirebaseError: [code=unknown]: Fetching auth token failed: Cannot redefine property: refreshToken

Simple application where I configure the firebase ...

import * as firebase from "firebase/app";
import 'firebase/auth';

const app = firebase.initializeApp(FIREBASE_CONFIG);
firebase.setLogLevel('debug');
app.auth().useDeviceLanguage();
app.auth().settings.appVerificationDisabledForTesting = __DEVELOPMENT__;

Then I configure the database

import 'firebase/firestore';
const database = app.firestore();
    database.settings({
        host: 'localhost:8080',
        ssl: true,
    });

With anonymous user

const handleAuthStateChanged = (user) => {
    if (!user) {
        firebase.auth().signInAnonymously();
    }
}
app.auth().onAuthStateChanged(handleAuthStateChanged)

And I tried to get some data

database.collection('events').doc(eventId).withConverter(eventConverter).get();

But I'm receiving this error

@firebase/firestore: Firestore (7.15.0): FirestoreClient Initializing. user= @firebase/firestore: Firestore (7.15.0): MemoryPersistence Starting transaction: Get next mutation batch @firebase/firestore: Firestore (7.15.0): MemoryPersistence Starting transaction: Allocate target @firebase/firestore: Firestore (7.15.0): MemoryPersistence Starting transaction: Execute query @firebase/firestore: Firestore (7.15.0): IndexFreeQueryEngine Using full collection scan to execute query: Query(target=Target(events/1, orderBy: [name (asc)]); limitType=F) @firebase/firestore: Firestore (7.15.0): PersistentStream close with error: FirebaseError: [code=unknown]: Fetching auth token failed: Cannot redefine property: refreshToken

@firebase/firestore: Firestore (7.15.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unknown]: Fetching auth token failed: Cannot redefine property: refreshToken

This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

and

FirebaseError: Failed to get document because the client is offline.


Works once I publish

If you go to .. https://nps-event.ridermansb.dev/event/1 you will see that it's working.

But locally is not working

Full source code here

https://github.com/Ridermansb/nps-event

like image 785
ridermansb Avatar asked May 03 '26 16:05

ridermansb


1 Answers

Firebase allows users to Implement its Authentication SDK to your sign in method. By reviewing your codes, I can see that Firebase Authentication anonymous signin method has been used here. It seems to be missing the error handling method in the method. You can refer to signInAonymously method documentation to add the error handling method to get more details about the error.

like image 52
Ying Li Avatar answered May 06 '26 07:05

Ying Li



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!