node.js - SYSTEM_ERROR: system encountered unexpected error. Function killed. Cloud functions -


when looked through logs firebase cloud functions, noticed functions have error in logs description of "system_error: system encountered unexpected error. function killed.", until yesterday, behavior not, here 1 of these functions. how can fix it?

const functions = require('firebase-functions'); const admin = require('firebase-admin');  module.exports = functions.database.ref('/cards/{cardid}/interestedusers').onwrite(event => {     const cardid = event.params.cardid;      console.log("interestedusers", event.data.val(), cardid);      var currentinterestedusers = [];     currentinterestedusers = event.data.val();     var previousinterestedusers = [];     previousinterestedusers = event.data.previous.val();      if (event.data.previous.val() && currentinterestedusers) {         var isnewpendingrequest = false;         if (currentinterestedusers.length < previousinterestedusers.length) {             currentinterestedusers.foreach((interesteduser, index) => {                 const interesteduserval = interesteduser.val();                 const isapproved = interesteduser["isapproved"];                 console.log("result", interesteduser.val(), interesteduserval);                 if (isapproved == false) {                     isnewpendingrequest = true;                 }             });         }          if (isnewpendingrequest == false) {             const cardref = admin.database().ref("cards").child(cardid);             const setupisnewpendingrequestpromise = cardref.update({                 "isnewpendingrequest": false             });             return promise.all([setupisnewpendingrequestpromise]);         };          return console.log("interestedusers deleting");     };      if (event.data.val() == null) {         console.log("event.data.val() == null");         const cardref = admin.database().ref("cards").child(cardid);         // check card         const cardcheckpromise = cardref.once("value", function(cardcheckpromisesnap, error){             if (error) {                 return console.log("cardcheckpromise", error);             };              if (cardcheckpromisesnap.val()) {                 const checkcardid = cardcheckpromisesnap.val()["id"];                 if (checkcardid)  {                     console.log("checkcardid", checkcardid);                     const setupisnewpendingrequestpromise = cardref.update({                         "isnewpendingrequest": false                     });                     return promise.all([setupisnewpendingrequestpromise]);                 } else {                     return console.log("checkcardid == null");                 }             } else {                 return console.log("cardcheckpromisesnap.val() == null");             };         });         return promise.all([cardcheckpromise]).catch(function(cardcheckpromiseerror){             console.log("cardcheckpromise error", cardcheckpromiseerror.message, cardcheckpromiseerror.messageid)         });     }       return console.log("just update or adding new interested user"); }); 

you can try re-deploying app.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -