Firebase cloud function crashes repeatedly due to quota error

I have a Firebase cloud function that runs onCreatealong the path in my Realtime database. Yesterday, after conducting basic testing, I began to receive errors with exceeding the quota in the cloud functions log. However, the alarm was that the error continued every time every 2 seconds or so, and then increased every 8 seconds or so for about 1.5 hours.

Here's a small segment of the problem:

Mistakes  Mistakes  More bugs.  * Sigh *

, Retrying Asynchronous Functions, , , , . , , , , , , , - . :

: ( DNS: 100 ); , https://console.cloud.google.com/billing?project=myproject. .

, , , Blaze, , , , , . , . , , , , , , , .

, , , Firebase Cloud. ( , ), : " ", , , - , , , .

, , , :

  • , , , , ? ?
  • , - ? ? , , , , , .

, , :

  • , , . , , .

  • , . DNS Resolutions 100 (, 5) , , 8 ​​ . , , , 10-20 , -, , 100 , . , , .

  • , Function execution took ### ms, finished with status 'ok' , . , . , , .

  • , , .

  • , , Blaze, . . , , .

+4
1

Firebase ( , ) , . , , , , .

-, , :

Firebase . , , . Firebase, , , , 100- . , < 100 .

, ...

, , , , ? ?

. , , . , . Firebase , , .

, , , Cloud Functions . .

, - ? ?

, . , , . , , .

...

, , MCVE I, Firebase Support, .

index.js

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

admin.initializeApp(functions.config().firebase);

const database = admin.database();

exports.helloWorld = functions.database.ref("/requests/" + "{pushKey}")
.onCreate(event  => {
    console.log("helloWorld: Triggered with pushKey: ", event.params.pushKey);

    //Say hello
    console.log("Hello, world! Don't panic!");

    let result = {};
    result["name"] = event.data.val().name;
    return database.ref("/responses/" + `${event.params.pushKey}/`).set(result)
    .then(() => {
        console.log("Response written to: " + `${event.params.pushKey}/`);
        return;
    })
    .catch((writeError) => {
        console.error("Response write failed at: " + `${event.params.pushKey}/`);
        return;
    });

});

package.json

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "./node_modules/.bin/eslint .",
    "serve": "firebase serve --only functions",
    "shell": "firebase experimental:functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "firebase-admin": "~5.8.1",
    "firebase-functions": "^0.8.1"
  },
  "devDependencies": {
    "eslint": "^4.12.0",
    "eslint-plugin-promise": "^3.6.0"
  },
  "private": true
}

{
  "requests" : [ null, {
    "name" : "Ford Prefect"
  }, {
    "name" : "Arthur Dent"
  }, {
    "name" : "Trillian"
  }, {
    "name" : "Zaphod Beeblebrox"
  }, {
    "name" : "Marvin"
  }, {
    "name" : "Slartibartfast"
  }, {
    "name" : "Deep Thought"
  }, {
    "name" : "Zarniwoop"
  }, {
    "name" : "Fenchurch"
  }, {
    "name" : "Babel Fish"
  }, {
    "name" : "Tricia McMillan"
  } ]
}

, GCP, 100 Firebase. , 4. "". ( 4 ), , 100- , . , Google, , FIFO , , , , , .

, ( ), , . , , , , .

Firebase .

0

Source: https://habr.com/ru/post/1692232/


All Articles