Preserve partial creation replies on stream failure
Some checks failed
CI / verify (push) Has been cancelled
Some checks failed
CI / verify (push) Has been cancelled
This commit is contained in:
@@ -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(['先把方洞万能的反差定住。']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user