fix(server): graceful stream termination on cancellation (issue #847) (#850)

* fix(server): graceful stream termination on cancellation (issue #847)

* Update the code with review suggestion
This commit is contained in:
Willem Jiang
2026-02-06 23:41:23 +08:00
committed by GitHub
parent ec46937384
commit f21bc6b83f
6 changed files with 91 additions and 9 deletions
+1
View File
@@ -84,6 +84,7 @@ export async function* chatStream(
});
for await (const event of stream) {
if (event.data == null) continue;
yield {
type: event.event,
data: JSON.parse(event.data),
+11 -1
View File
@@ -84,10 +84,20 @@ export interface CitationsEvent {
};
}
export interface ErrorEvent {
type: "error";
data: {
thread_id: string;
error: string;
reason?: "cancelled" | string;
};
}
export type ChatEvent =
| MessageChunkEvent
| ToolCallsEvent
| ToolCallChunksEvent
| ToolCallResultEvent
| InterruptEvent
| CitationsEvent;
| CitationsEvent
| ErrorEvent;