Closed aliozinan closed 5 years ago
Update
firebase-functions version 16.3.0, released 15 Mar 2019, adds the ability to configure the timeout.
Looks like the Google Team came up with a solution and set the default timeout to 60 seconds for callable functions. I'll be sharing the test results here.
Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
@aliozinan any news? I'm also stuck with the 10 second timeout here and am wondering if you learned something new?
@bitfabrikken Here is a workaround for this issue. Since the limitation is within the library for HTTP requests used by react-native-firebase, we tried to use another one. So instead of use functions().httpsCallable(), we decided to call the function with a http client like axios.
We were concerned about authentication, because if you call the function in this way, the function won't receive the context object. Hopefully, firebase automaticaly validates a bearer token that you can provide in the Authorization header, and populates the context object.
Here's my example
import { auth } from 'react-native-firebase';
import axios from 'axios';
export const functionsHttpCallable = async () => {
// Get the token for the logged user
const token = await auth().currentUser.getIdToken();
// Do the request
return axios.post(
'<Your Firebase Cloud Function URL>',
{
data: { 'parameters of the function' }
},
{
headers: {
'Content-Type': 'application/json',
// This will be automatically validated in the server
Authorization: `Bearer ${token}`
},
transformResponse: [
response => {
const res = JSON.parse(response);
// unwrap the object returned by the function
return res.result;
}
]
}
);
}
You can parametrize that function with the name of the cloud function, the token, and the parameters to send.
Hope it helps!
It seems like Google's update I mentioned above must be implemented on react-native-firebase side as well. Now that there's the timeout parameter available for HttpsCallableReference, the team can do something about it I guess?
@aliozinan PRs are welcome if you’d like to propose one
it does seem valid to re-open this one as no longer blocked though?
@aliozinan PRs are welcome if you’d like to propose one
I would love to, if I knew how to code Java
it does seem valid to re-open this one as no longer blocked though?
Yes this issue is still unresolved and needs to be re-opened. It was closed by the bot, I cannot re-open it.
Issue
:fire:
Callable functions are returning HttpsError: timeout. The reason of the issue is the default 10 seconds limitation of the Java library used for HTTP requests. If a callable function runs over 10 seconds, even it goes on running and completes its job on Firebase server, the library throws timeout error on the client side. I raised a request to the Google Cloud Team long time ago but it's still not resolved. A workaround solution has been provided below, which could be considered to be implemented :
https://stackoverflow.com/questions/50971356/firebase-cloud-functions-change-timeout
Project Files
iOS
ios/Podfile
:AppDelegate.m
:Android
android/build.gradle
:android/app/build.gradle
:android/settings.gradle
:MainApplication.java
:AndroidManifest.xml
:Environment
Android API 21 to 28
N/A
N/A
Ubuntu 16.04
React Native
version:React Native Firebase
library version:Firebase
module(s) you're using that has the issue:TypeScript
?N/A
ExpoKit
?ExpoKit