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
This commit is contained in:
AgentSeal 2026-04-14 01:31:31 -07:00
parent c7c6a0d2ec
commit 3964478e61

View file

@ -281,7 +281,12 @@ async function parseSessionFile(
seenMsgIds: Set<string>,
dateRange?: DateRange,
): Promise<SessionSummary | null> {
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[] = []