Preserve partial creation replies on stream failure
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
kdletters
2026-05-05 11:31:50 +08:00
parent 100fee7e7a
commit 995661e7cc
299 changed files with 13805 additions and 1429 deletions

View File

@@ -51,3 +51,28 @@ test('readCreationAgentSessionFromSse flushes decoder tail and handles CRLF boun
title: '世界共创',
});
});
test('readCreationAgentSessionFromSse keeps streamed updates before error event', async () => {
const encoder = new TextEncoder();
const response = createChunkedStreamResponse([
encoder.encode(
'event: reply_delta\ndata: {"text":"先把方洞万能的反差定住。"}\n\n',
),
encoder.encode(
'event: error\ndata: {"message":"方洞挑战聊天生成失败LLM 请求超时"}\n\n',
),
]);
const updates: string[] = [];
await expect(
readCreationAgentSessionFromSse(response, {
fallbackMessage: '发送失败',
incompleteMessage: '结果不完整',
onUpdate: (text) => {
updates.push(text);
},
}),
).rejects.toThrow('方洞挑战聊天生成失败LLM 请求超时');
expect(updates).toEqual(['先把方洞万能的反差定住。']);
});