I'm calling a Firebase callable function, and returning the promise as specifed by Firebase, but I get this error:
Unhandled error RangeError: Maximum call stack size exceeded
Here's the code:
exports.getProductInfo = functions.https.onCall((data, context) => {
// Message text passed from the client.
const product = data.product;
// Authentication / user information is automatically added to the request.
// const uid = context.auth.uid;
// Get the current Server Timestamp
var ts = String(Date.now());
var key, snap, node;
// Get the price of the specified product
return database.ref('/products/' + product)
.orderByKey()
.endAt(ts)
.limitToLast(1)
.once('value', function (snapshot) {
snap = snapshot.val();
console.log('snap: ' + JSON.stringify(snap));
key = Object.keys(snap)[0];
node = snap[key];
console.log('node: ' + JSON.stringify(node));
return(node);
});
});
Here's the output that I see in my function log:
snap: {"1538004276":{"description":"This the the Basic product","price":40}}
node: {"description":"This the the Basic product","price":40}
Unhandled error RangeError: Maximum call stack size exceeded
at Object (native)
at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:4905:24
at baseForOwn (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:2996:24)
at Function.mapValues (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13401:7)
at encode (/user_code/node_modules/firebase-functions/lib/providers/https.js:242:18)
at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13402:38
at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:4911:15
at baseForOwn (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:2996:24)
at Function.mapValues (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13401:7)
at encode (/user_code/node_modules/firebase-functions/lib/providers/https.js:242:18)
at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13402:38
at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:4911:15
at baseForOwn (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:2996:24)
at Function.mapValues (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13401:7)
at encode (/user_code/node_modules/firebase-functions/lib/providers/https.js:242:18)
at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13402:38
at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:4911:15
at baseForOwn (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:2996:24)
at Function.mapValues (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13401:7)
at encode (/user_code/node_modules/firebase-functions/lib/providers/https.js:242:18)
at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13402:38
at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:4911:15
at baseForOwn (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:2996:24)
at Function.mapValues (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13401:7)
Help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…