title: Firebase Unhandled error RangeError: Maximum call stack size exceeded
body: <p>I'm calling a Firebase callable function, and returning the promise as specifed by Firebase, but I get this error:</p>
  
  <p>Unhandled error RangeError: Maximum call stack size exceeded</p>
  
  <p>Here's the code:</p>
  
  <pre><code>exports.getProductInfo = functions.https.onCall((data, context) =&gt; {
    // 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);
                   });
  });
  </code></pre>
  
  <p>Here's the output that I see in my function log:</p>
  
  <p>snap: {"1538004276":{"description":"This the the Basic product","price":40}}</p>
  
  <p>node: {"description":"This the the Basic product","price":40}</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Help!</p>