1

This is the only function I deployed:

exports.gameAction = functions.https.onCall((data, context) => { 
    const timeoutRef = admin.database().ref('/current_player/timeout');
    return timeoutRef.transaction((timeout) => {
        return;
    });
});

If I understand this correctly, the transaction will abort at once after calling, but when I call this function from my app, the console shows the error below:

Unhandled error RangeError: Maximum call stack size exceeded
    at Object (native)
    at baseGetTag (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:3087:51)
    at Function.isBoolean (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:11383:33)
    at encode (/user_code/node_modules/firebase-functions/lib/providers/https.js:229:11)
    at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13400:38
    at /user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:4925:15
    at baseForOwn (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:3010:24)
    at Function.mapValues (/user_code/node_modules/firebase-functions/node_modules/lodash/lodash.js:13399: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:13400:38

What am I missing here?

1 Answer 1

1

The way onCall functions send data back to the client is by returning a promise that resolves with the object data to send. Therefore, Cloud Functions is trying to serialize the data contained by promise returned by transaction, then send it in JSON format to the client.

As you can see from the API documentation for transaction(), the promise contains a Reference object, which contains all kinds of metadata about the reference. It probably contains a circular data structure, and Cloud Functions is hung up on trying to serialize an infinite loop.

Try returning something less complex from your function instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.