Skip to content

parity(functions): stream text/event-stream responses instead of buffering the body [from supabase-js] #416

Description

@fresh55

sdk-compliance.yaml still marks functions.invocation.streaming_response as partially_implemented. RawInvoke returns HttpContent but the send in RetryExecutor uses the default ResponseContentRead, so the whole body is buffered before it returns. a text/event-stream function (ai chat, progress events) is only readable once it has finished.

js, flutter, swift and kotlin all hand back the live response for text/event-stream:
https://github.com/supabase/supabase-js/blob/master/packages/core/functions-js/src/FunctionsClient.ts

Invoke can't branch on content type and i'd rather not add a flag to it, so a separate method like swift and kotlin have:

Task InvokeStream(string functionName, string? token = null, InvokeFunctionOptions? options = null, CancellationToken cancellationToken = default);

sends with ResponseHeadersRead, no retry once headers arrive, HttpTimeout covers the headers only, caller disposes the response. sse parsing can come later ( at least i propose new issue and new PR for it ) .

upstream is supabase/functions-js#74 from 2024, so not a recent js change

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions