Skip to content

streaming callable API: client aborted stream -> how to know on server? #1684

Open
@Obiwarn

Description

@Obiwarn

I am testing the new streaming API for cloud functions in emulator.
Aborting streams with an AbortController on my client works fine.

How can the called function know that the user canceled the stream? The CallableResponse signal does not fire an event.

I want to pass an abort signal to the AI API I am calling in the function.

export const aiStreamText = onCall<AiStreamTextRequest>(
  async (request, response) => {
    response?.signal.addEventListener("abort", () => {
      console.log(new Date().toISOString(), "on server: aborted by user");  // THIS DOES NOT FIRE ON ABORT
    });

Related issues

[REQUIRED] Version info

node:

firebase-functions:

firebase-tools:

firebase-admin:

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

[REQUIRED] Expected behavior

[REQUIRED] Actual behavior

Were you able to successfully deploy your functions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions