mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 20:03:13 +08:00
优化停止,出现API Error: Stream ended without receiving any events
优化停止,出现API Error: Stream ended without receiving any events
This commit is contained in:
@@ -1407,6 +1407,13 @@ export function translateCliMessage(cliMsg: any, sessionId: string): ServerMessa
|
||||
switch (cliMsg.type) {
|
||||
case 'assistant': {
|
||||
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 code = typeof cliMsg.error === 'string' ? cliMsg.error : 'API_ERROR'
|
||||
streamState.lastApiError = { message, code }
|
||||
|
||||
Reference in New Issue
Block a user