firebase / firebase/firebase-functions

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

Open
#1,684 6 comments 2 reactions 0 assignees View on GitHub
feature request needs-attention
Dominant language
TypeScript
Stars
1.1k
Forks
232
Avg merge
20h 46m
Merged PRs (30d)
15

Description

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(
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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.