mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-26 15:03:34 +08:00
Merge pull request #883 from zhbdesign/patch-5
优化停止,出现API Error: Stream ended without receiving any events
This commit is contained in:
commit
dbb2ad08ac
@ -1407,6 +1407,13 @@ export function translateCliMessage(cliMsg: any, sessionId: string): ServerMessa
|
|||||||
switch (cliMsg.type) {
|
switch (cliMsg.type) {
|
||||||
case 'assistant': {
|
case 'assistant': {
|
||||||
if (cliMsg.error || cliMsg.isApiErrorMessage) {
|
if (cliMsg.error || cliMsg.isApiErrorMessage) {
|
||||||
|
// If the user requested stop, suppress API errors caused by the
|
||||||
|
// stream being interrupted (e.g. "Stream ended without receiving
|
||||||
|
// any events"). The result message handler also checks this flag,
|
||||||
|
// but the assistant error arrives first and would leak to the UI.
|
||||||
|
if (sessionStopRequested.has(sessionId)) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
const message = extractAssistantText(cliMsg) || cliMsg.error || 'Unknown API error'
|
const message = extractAssistantText(cliMsg) || cliMsg.error || 'Unknown API error'
|
||||||
const code = typeof cliMsg.error === 'string' ? cliMsg.error : 'API_ERROR'
|
const code = typeof cliMsg.error === 'string' ? cliMsg.error : 'API_ERROR'
|
||||||
streamState.lastApiError = { message, code }
|
streamState.lastApiError = { message, code }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user