-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support streaming streaming responses for callable functions. #8609
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: b9a42e5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1Affected Products
Test Logs |
…e-js-sdk into dl-fn-streaming
Changeset File Check ✅
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI stuff that you want to do before you finalize and merge:
(1) To address the formatting CI failure, run yarn format
locally.
(2) To address the docgen failure, run yarn docgen:all
locally. This will modify some files in docs-devsite
which will require a techwriter review approval in addition to a JS core team review. go/firebase-contacts tells me the techwriter assigned to CF3 is Eric Gilmore.
long: 420 | ||
}); | ||
} catch (err) { | ||
console.error(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a chai error, too, I think.
export interface HttpsCallableStreamOptions { | ||
/** | ||
* An AbortSignal that can be used to cancel the streaming response. When the signal is aborted, | ||
* both the underlying connection and stream will be terminated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe that's true, but I could be wrong. I added some Abort Signals to the Gemini SDK, and in doing that I learned that Abort doesn't close the connection, it just stops listening for network responses at the application level. Therefore the server operation might continue to move forward, the app just wont' be notified of the result.
Does that affect billing or usage concerns?
@@ -244,10 +275,30 @@ async function postJSON( | |||
}; | |||
} | |||
|
|||
async function makeAuthHeaders( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a function description comment block above this?
}; | ||
} | ||
|
||
function createResponseStream( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A header here, too, please.
The new
.stream()
API allows the client to consume streaming responses from the WIP streaming callable functions in Firebase Functions Node.js SDK.When client makes a request to the callable function w/ header
Accept: text/event-stream
, the callable function responds with response chunks in Server-Sent Event format.The sdk changes here abstracts over the wire-protocol by parsing the response chunks and returning an instance of a
AsyncIterable
to consume to data: