I recieve an error Error: open EEXIST
when i am trying to get data from firebase on a node service.
I attached code below. It is in the collectionRef.get()
it gives error.
It is working in local environment. I have verified the env-credentials and they seem ok.
async function fetchCollectionData(collectionName) {
try {
logToFile(`Initiating request to firebase for collection: ${collectionName}`);
const collectionRef = db.collection(collectionName);
const snapshot = await collectionRef.get();
logToFile(`Request to firebase completed for collection: ${collectionName}`);
const returnValues = snapshot.docs.map(doc => doc.data());
logToFile(`Data fetched for collection: ${collectionName}`);
return returnValues;
} catch (error) {
logToFile('Error fetching documents: ' + error);
throw new Error('Server error! ' + error.message);
}
}
I have made sure that I don’t create any more instances of firebase
if (!admin.apps.length) {
try {
console.error('Initializing Firebase');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
console.error('Firebase Admin SDK initialized successfully');
} catch (error) {
console.error('Error initializing Firebase Admin SDK:', error);
}
}
const db = admin.firestore();
module.exports = db;
Anyone that can help?
New contributor
buffetwarren is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.