Skip to content

Commit 21d6303

Browse files
Fix uncaught error in ai conversation endpoint
1 parent a70a5dc commit 21d6303

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

packages/server/api/src/app/ai/chat/ai-mcp-chat.controller.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,14 @@ export const aiMCPChatController: FastifyPluginAsyncTypebox = async (app) => {
225225
try {
226226
await handleNewMessage(request, reply);
227227
} finally {
228-
// Flush traces to Langfuse (critical for Fastify)
229228
const spanProcessor = getLangfuseSpanProcessor();
230229
if (spanProcessor) {
231-
await spanProcessor.forceFlush();
232-
logger.debug('Flushed Langfuse traces');
230+
try {
231+
await spanProcessor.forceFlush();
232+
logger.debug('Flushed Langfuse traces');
233+
} catch (error) {
234+
logger.error('Failed to flush Langfuse traces', { error });
235+
}
233236
}
234237
}
235238
});

0 commit comments

Comments
 (0)