-
Notifications
You must be signed in to change notification settings - Fork 204
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
Improve callable function for long running requests. #1635
Conversation
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'm confused by the example you provided. Why are we awaiting response()
for the final return value?
const scheduleHeartbeat = () => { | ||
clearScheduledHeartbeat(); | ||
if (!abortController.signal.aborted) { | ||
heartbeatInterval = setTimeout(() => { |
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.
Why not use setInterval()?
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.
Using setTimeout
instead since I'm trying ton control more precisely whether next "tick" should happen or not. That's why this call is recursive.
In #1634, we introduced new API to return response chunks for callable functions. This means that callable function response my be long-running.
To ensure that long-running requests are handled well, we are adding 2 new features:
heartbeat: Some network proxies may close request connection when no response data is sent for some time interval. By default, callable function will send a heartbeat ping every 30 seconds. Our client SDKs will ignore these pings. Users can disable heartbeat for streaming response by setting
heartbeatSeconds
configuration tonull
.AbortSignal:
response
object of the callable handler will now includesignal
property which the developer can use to check and see if a client connection has been dropped. They can forward this signal property tofetch
-like APIs so that underlying calls would be terminated properly.e.g.