Skip to content

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

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

Open
Obiwarn opened this issue Mar 26, 2025 · 3 comments
Open

Comments

@Obiwarn
Copy link

Obiwarn commented Mar 26, 2025

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?

@google-oss-bot
Copy link
Collaborator

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

@CorieW
Copy link
Contributor

CorieW commented Apr 2, 2025

Hi @Obiwarn,

Thanks for reporting this issue! We’ve received it and are reviewing it. We’ll provide updates as soon as possible.

@CorieW
Copy link
Contributor

CorieW commented Apr 15, 2025

After attempting this for myself, I'm not sure this is possible, however, I will raise internally to confirm. For now, I will leave a feature-request label.

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

No branches or pull requests

3 participants