javascript - Cloud Functions for Firebase timeout -


simple cloud function database data not working.

getusermessage() not working

error:

function execution took 60002 ms, finished status: 'timeout'

index.js getting database result.

const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeapp(functions.config().firebase); const cors = require('cors')({origin: true});  // take text parameter passed http endpoint , insert // realtime database under path /messages/:pushid/original exports.addmessage = functions.https.onrequest((req, res) => {   // grab text parameter.   const original = req.query.text;   // push new message realtime database using firebase admin sdk.   admin.database().ref('/messages').push({original: original}).then(snapshot => {     // redirect 303 see other url of pushed object in firebase console.     res.redirect(303, snapshot.ref);   }); });  // listens new messages added /messages/:pushid/original , creates // uppercase version of message /messages/:pushid/uppercase exports.makeuppercase = functions.database.ref('/messages/{pushid}/original')     .onwrite(event => {       // grab current value of written realtime database.       const original = event.data.val();       console.log('uppercasing', event.params.pushid, original);       const uppercase = original.touppercase();       // must return promise when performing asynchronous tasks inside functions such       // writing firebase realtime database.       // setting "uppercase" sibling in realtime database returns promise.       return event.data.ref.parent.child('uppercase').set(uppercase);     });  var db = admin.database(); exports.getusermessage = functions.https.onrequest((req, res) => { var query = db.ref("messages").orderbykey(); query.once("value")   .then(function(snapshot) {     snapshot.foreach(function(childsnapshot) {       var key = childsnapshot.key;       // childdata actual contents of child       var childdata = childsnapshot.val();   }); });   }); 

what o doing wrong?

you didn't of 3 functions timing out, i'll take guess @ one. https function getusermessage isn't generating response client. cloud functions wait 60 seconds (by default) generate response, , if doesn't, kill function , leave message in log.

every code path in https function should generate response client.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -