From 3964478e61cfcc45def9899c109723cc8dfae6ff Mon Sep 17 00:00:00 2001 From: AgentSeal Date: Tue, 14 Apr 2026 01:31:31 -0700 Subject: [PATCH] fix: handle unreadable session files gracefully readFile in parseSessionFile had no error handling. If a .jsonl file is missing, has bad permissions, or gets deleted between readdir and readFile, the whole process crashes with ENOENT. Now returns null and skips the file. Fixes #9 --- src/parser.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/parser.ts b/src/parser.ts index 5bbba561..29d372db 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -281,7 +281,12 @@ async function parseSessionFile( seenMsgIds: Set, dateRange?: DateRange, ): Promise { - const content = await readFile(filePath, 'utf-8') + let content: string + try { + content = await readFile(filePath, 'utf-8') + } catch { + return null + } const lines = content.split('\n').filter(l => l.trim()) const entries: JournalEntry[] = []