0

I'm trying to access my the firestore data within a Firebase function... I'm new at Firebase and didn't understand exactly somethings... I read lots of the documentation and FAQs and nothing explain my question.

Here it is:

I create a Firebase project test-123xyz. Then I install firebase tools in my terminal. In the web console I create a firestore database. Then I run firebase init in terminal, select an existing project (the test-123xyz) and select the function, hosting and firestore services.

The code in the function is:

const functions = require('firebase-functions');
const express = require('express');
const admin = require("firebase-admin");

admin.initializeApp();

const firestore = admin.firestore();
const app = express();

app.get('/api/usuarios', (req, res) => {

  firestore.collection("usuarios").get()
   .then(doc => {
     return res.send(doc.data());
   }).catch(error => {
     return res.status(500).send(error);
   });

})

exports.app = functions.https.onRequest(app);

It works pretty fine. It access and write in the database. All good. I access the page *MY_PROJECT.firebaseapp.com/api/cardapio/hoje* and get the JSON.

But then I notice this alert in the billing console in Firebase on Outbounding network

enter image description here

All the others usage is ok, inside the limit. But the way I'm accessing the firestore is counting as an outbounding task.

But I though the usage of firestore is inside the limit of the Spark plan:

enter image description here

My question is: Is the a diferent way to access the firestone within a firebase function that make this works. Or if I want to access the database from a function I need to pay this as an outbounding connection?

*Edit:

This is the log of the function:

enter image description here

1 Answer 1

1

Accessing Firestore from within a function does not count as "outbound networking". You should have no problems querying Firestore until the specific free quotas for Firestore have been exhausted.

It sounds like to me that your function is actually still working OK, but you are confused by the alert. It's possible that there is just something wrong with the console, and it's counting something as "outbound networking" when it really is not.

I suggest contacting Firebase support directly with your concern, since the code you're showing right now should not incur any outbound networking. And, being on the spark plan, you should not be getting billed anyway.

Sign up to request clarification or add additional context in comments.

3 Comments

I will do that. But if I access the route MY_PROJECT.firebaseapp.com/api/cardapio/hoje, after something like 10 minutes the traffic is increased in that outbounding alert in console. There is no doubt that it's couting as a outbounding. I will include the LOG from function in the question.
That log is always there for projects where no billing is enabled. It shouldn't affect the way your function works as you're showing it now. You can do a search for that text to confirm.
Well...I received a response from the contacting. It ends up that you are right. The outbounding network it's a metric for Google's engineers and shouldn't being displayed in my console. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.