From ae90d80cfee6d084a7a252c19b2477c10a154fbc Mon Sep 17 00:00:00 2001 From: can1357 Date: Fri, 13 Feb 2026 12:39:14 +0100 Subject: [PATCH] fix(stats): skip malformed JSONL lines during session sync --- packages/stats/src/parser.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/stats/src/parser.ts b/packages/stats/src/parser.ts index e09faa559..236e81d29 100644 --- a/packages/stats/src/parser.ts +++ b/packages/stats/src/parser.ts @@ -72,12 +72,16 @@ export async function parseSessionFile( for (const line of lines) { const lineLength = line.length + 1; // +1 for newline if (line.trim()) { - const entry = JSON.parse(line) as SessionEntry; - if (currentOffset >= fromOffset && entry && isAssistantMessage(entry)) { - const msgStats = extractStats(sessionPath, folder, entry); - if (msgStats) { - stats.push(msgStats); + try { + const entry = JSON.parse(line) as SessionEntry; + if (currentOffset >= fromOffset && entry && isAssistantMessage(entry)) { + const msgStats = extractStats(sessionPath, folder, entry); + if (msgStats) { + stats.push(msgStats); + } } + } catch { + // Skip malformed JSONL lines } } currentOffset += lineLength;