🐛 [@react-native-firebase/functions] Missing `stream` implementation for `httpsCallable` functions
Hey amazing invertase team! Happy new year!
In Dec 2024, a PR was merged into firebase-js-sdk that allows you to stream responses from Firebase functions which is awesome! I've tried it out on web and it works wonderfully. Would be awesome if this could be implemented in RN Firebase Functions!!! :D
Neat, wasn't aware of that work.
I believe we'll need underlying SDK support prior to us being able to do anything at this layer above them
iOS: https://github.com/firebase/firebase-ios-sdk/pull/14290 Android: https://github.com/firebase/firebase-android-sdk/pull/6602
After that we'll have a fair bit of work here to wrap them and present them in a manner compatible with firebase-js-sdk (or we'd happily accept a PR of course...)
The only thing I can think of in the meantime is that you can actually use the firebase-js-sdk alongside react-native-firebase if you like. It is bundled with react-native-firebase as it is used as a fallback for "other" platform support already internally here. You'll have to initialize an app manually after react-native-app boot just like you do on web, and if you use AppCheck you'll have to set the firebase-js-sdk functions headers with it after fetching it from react-native-firebase/app-check, similar with auth - but those headers shouldn't be too hard to set ?
I looked into using firebase-js-sdk alongside, but I think the issue is that on React Native, the fetch implementation doesn't support ReadStream. Seems like a common problem. However I found that Expo SDK 52 provides a fetch implementation that is winter cg compliant that supports streaming, so I'm currently updating my app to use that instead and will just manually stream from the firebase function I think :) I can get the Bearer token from firebase auth using getIdToken() so should be all good to go 🙏 would be awesome if the RN firebase supported it but I understand its probably a big chunk of work.
Is a big chunk of work to support it here but most importantly we can't do anything not provided by the underling native android and iOS SDKs, so we are necessarily blocked on them regardless.
Very nifty that it looks like it'll be possible to "weld together" the firebase-js-sdk library support for it while still using react-native-firebase for it's native-only stuff though
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Still requires attention
@harveyappleton there's nothing we can do here, I just paid attention to it but it unfortunately wasn't attention well spent. Without upstream support there is nothing we can do, and it hasn't landed there as far as I know.
You might look at the VertexAI implementation that we'll be landing soon though - it was able to use react-native fetch plus some polyfills to get readable stream support using javascript. That strategy can work:
https://github.com/invertase/react-native-firebase/pull/8236/files#diff-f22d3ccf7d705193a63381ca0d16187ba37c273cfaa52cbaac399f237f3e9278
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Streaming callable functions appears to have landed in firebase-android-sdk (33.11.0) and firebase-ios-sdk (11.10.0) now, this should be possible to implement now
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
@mikehardy Hi, is there have any plan for this?
can we have a RN streaming callable yet?
possibly yes - I'll reopen, in addition to SDK support, react-native itself has a lot of issues with streams because the underlying implementations are incomplete upstream in react-native. However we've gotten pretty good at polyfilling them with success here in our implementation of remote-config realtime updates and the AI session streaming so there should be no technical reason we can't (as long as the polyfills in those packages are adopted). Open to PRs of course, but this is valid for the issue backlog either way
that would be amazing @mikehardy! this is sorely needed for LLM streaming apps. The workarounds with onRequest and Xhr feel so 2008.
Related, (but not critical if RN starts to support Streaming Callables) is that fetch in RN also does not support ReadableStream/response.body.getReader() so there's workarounds on top of workarounds we're resorting to today.
Would be happy to help test! tysm!
Check the polyfill file and related deps in our ai and remote-config package for a readable stream fix that works for us
+1
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
+1
There is a streaming functions PR in the works
- #8772