Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
999 views
in Technique[技术] by (71.8m points)

google cloud functions - Firebase Unhandled error RangeError: Maximum call stack size exceeded

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...