Skip to content

Commit 4a7ac04

Browse files
committed
Address bugbot
1 parent e17576c commit 4a7ac04

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

apps/sim/lib/copilot/chat-streaming.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ export function createSSEStream(params: StreamingOrchestrationParams): ReadableS
245245
}
246246
}
247247

248+
const pushEventBestEffort = async (event: Record<string, any>) => {
249+
try {
250+
await pushEvent(event)
251+
} catch (error) {
252+
logger.error(`[${requestId}] Failed to push event`, {
253+
eventType: event.type,
254+
error: error instanceof Error ? error.message : String(error),
255+
})
256+
}
257+
}
258+
248259
if (chatId) {
249260
await pushEvent({ type: 'chat_id', chatId })
250261
}
@@ -308,7 +319,7 @@ export function createSSEStream(params: StreamingOrchestrationParams): ReadableS
308319
logger.error(`[${requestId}] Orchestration returned failure`, {
309320
error: errorMessage,
310321
})
311-
await pushEvent({
322+
await pushEventBestEffort({
312323
type: 'error',
313324
error: errorMessage,
314325
data: {
@@ -348,7 +359,7 @@ export function createSSEStream(params: StreamingOrchestrationParams): ReadableS
348359
}
349360
logger.error(`[${requestId}] Orchestration error:`, error)
350361
const errorMessage = error instanceof Error ? error.message : 'Stream error'
351-
await pushEvent({
362+
await pushEventBestEffort({
352363
type: 'error',
353364
error: errorMessage,
354365
data: {

0 commit comments

Comments
 (0)