In emulators, realtime database, firestore write (via emulator functions) is showing success but can't see data in the firebase console
See original GitHub issue[REQUIRED] Environment info
firebase-tools: 7.3.2
Platform: Ubuntu
[REQUIRED] Test case
In emulator, I’m writing to realtime database and firestore, via emulator functions. The write shows success, but I can’t see it’s written to db (firestore, rtdb) in firebase console.
[REQUIRED] Steps to reproduce
Cloud functions:
exports.singleTask = functions.https.onRequest((req, res) => {
return admin.database().ref(`admin/singleTask/done`)
.transaction((current_value) => {
console.log(current_value);
if (current_value === null || current_value === 0) {
return (current_value || 0) + 1;
} else {
//eslint-disable-next-line consistent-return
return; // Abort the transaction.
}
})
.then((trans) => {
if (trans.committed) {
return firestore.doc('col/doc1').set({'key': 'val'});
} else {
return Promise.reject(new Error('duplicate'));
}
})
.then(_commit => {
return res.send('updated');
})
.catch((err) => {
if (err.message === 'duplicate') {
return res.send('duplicate')
}else{
console.error(err);
return res.send('error')
}
})
});
[REQUIRED] Expected behavior
In firebase console, RTDB, admin/singleTask/done
should be set to 1
&&
in firestore, col/doc1
should contain key: "val"
[REQUIRED] Actual behavior
Write is successfull in cloudfunctions, but not showing in console.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Connect your app to the Cloud Firestore Emulator - Firebase
Connect your app to the Cloud Firestore Emulator · Choose a Firebase project · Instrument your app to talk to the emulators ·...
Read more >Access Firebase Realtime database/Firestore from Cloud ...
If you are retrieving some data from Firebase Realtime Database Emulator, first make sure that you imported some data.
Read more >Testing security rules | Firestore - Google Cloud
The Firestore emulator lets you visualize client requests in the Emulator Suite UI, including evaluation tracing for Firebase Security Rules. Open the Firestore...
Read more >Seeding mock data to the Firebase Local Emulator Suite
Then in your app's firebase.js file, include an if statement that checks your Node environment. If you are in 'development' mode your app...
Read more >Building a REST API with Firebase cloud functions, TypeScript ...
With that done, when you revisit the functions page on your Firebase console, you should see a new function named app and its...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@hkchakladar for Firestore there’s no easy way to view data in your browser, we’re working on it!
If you want to write back to production, you should not run the DB emulators. So
firebase emulators:start --only functions
. Then any code that runs in the function will talk to production. Of course then you can’t trigger the functions based on local DB events but that would be a strange combination anyway.@hkchakladar that’s the intended behavior because it is writing back to the Database Emulator, which can’t be seen by the console.
You can view the data by going to: http://localhost:PORT/admin/singleTask/done.json?ns=YOUR_PROJECT_ID
Make sure to replace PORT with the port the RTDB emulator is using and YOUR_PROJECT_ID with your Firebase project ID.