'Firebase Cloud Function call on Android randomly throws an "Internal Error" exception

I call a Firebase Cloud Function from my app and most of the times it works normally, but from time to time (I would say twice a day) an invocation, after a long time, produces an "Internal Error" exception.

Apparently the invocation is not even done, because no record of the function's execution is registered in the Firebase logs on the server. To confirm this, I tried to call another very simple cloud function (see below) just after the ocurrence and this invocation also fails.

const functions = require('firebase-functions');
module.exports = functions.https.onCall((whatever, context) => {
  return true;
});

This situation happens only when the app is running on Android devices.

I´ve already tried to implement the retry strategy suggested here: https://cloud.google.com/storage/docs/retry-strategy, to no avail. I´ve implemented a timer to forcibly cancel the task, so the retry strategy could be implemented, but no matter how many times I repeat the invocation, it always fails.

I suspect the connection with the Firebase server is somehow being lost. How can I force a reconnection? Is there anything else I can do to solve this problem?

The app is still under development (the load on the Firebase servers is minimal and sporadic), but I´m afraid I won't be able to launch it until I solve this problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source