Repository navigation
fix: one unprobeable .jsonl no longer blanks the whole usage dashboard - #79
Conversation
sortUsageFilesByEarliestTimestamp mapped readEarliestTimestamp over every file with no per-file error handling. A file that trips the probe's 1 MiB no-timestamp guard (TimestampProbeLimitError), such as a large workflow journal.jsonl, rejected the whole batch, so loadUsageRecords returned empty records and the dashboard blanked on every refresh (failed=1, bytes=0). Catch the per-file failure and fall back to timestampMs 0 so the file sorts by discovery order, matching the existing small-no-timestamp behavior. The rest of the load proceeds and the file still reaches the main reader. readEarliestTimestamp and its test are unchanged. Adds a regression test.
|
🤖 Automated first-pass review **TL;DR** Correct, well-structured fix that handles the degenerate case cleanly. Follows project conventions (no new dependencies, CHANGELOG updated, test added). Merge-ready.Analysis
**Suggested 🤖 Generated by DeepSeek as an automated first pass — not a maintainer decision. |
Keep both the timestamp-probe and Opus 5 changelog entries while updating the original contributor branch. Co-authored-by: OpenAI Codex <215057067+openai-codex[bot]@users.noreply.github.com>
大家好
Problem
sortUsageFilesByEarliestTimestampmapsreadEarliestTimestampover everydiscovered
.jsonlviamapWithConcurrency, with no per-file error handling.readEarliestTimestampthrowsTimestampProbeLimitErrorwhen a file has morethan 1 MiB of leading lines that carry no
timestampfield (covered by theexisting "timestamp probing is bounded when no valid timestamp exists" test).
That rejection is unhandled, so
Promise.allrejects, the error unwinds out ofloadUsageRecords, and the outer catch returns{ records: [] }withfilesFailed = Math.max(filesFailed, 1). A single such file empties the entirefile-based dashboard on every refresh. Diagnostics report
failed=1withbytes=0. The API quota path is separate and keeps working, so only theusage/history panel goes blank.
The file type that triggers this in normal use is a workflow
journal.jsonl:its records contain
type,key,result, andagentId, never atimestamp, and a workflow run with a few hundred sub-agents produces ajournal.jsonlover 1 MiB.Origin
This surfaced from Claude Code's Workflow feature (multi-agent orchestration).
Each run writes a journal at
~/.claude/projects/<project>/<session>/subagents/workflows/<workflow-id>/journal.jsonl,one line per sub-agent lifecycle event: a
startedline and aresultlineper agent, each holding
type,key,result, andagentIdand notimestamp. Theresultvalues make some lines large. A single run thatfanned out to roughly two hundred sub-agents produced a 1.32 MB, 402-line
journal, over the 1 MiB probe limit. From then on every refresh returned empty
records (
failed=1,bytes=0) and the dashboard stayed blank while thestatus-bar quota kept updating, which presented as a rendering fault rather
than a load abort.
Reproduction
Create a
.jsonlunder~/.claude/projects/<project>/whose first 1 MiBcontains no line with a
timestampfield:Equivalently, run any workflow whose
subagents/workflows/<id>/journal.jsonlgrows past 1 MiB.Open the extension or trigger a refresh.
The dashboard is empty. Show Diagnostic Logs reports
failed=1andbytes=0on every refresh, while the status-bar quota continues to update.
With the fix, the same setup loads the remaining files normally and the
dashboard populates; the oversized file is skipped for ordering.
Fix
Catch the per-file probe failure in
sortUsageFilesByEarliestTimestampand fallback to
timestampMs: 0, so the file sorts by discovery order — the same valuereadEarliestTimestampalready returns for a small file that has no timestamp.One unprobeable or transiently unreadable file no longer aborts the batch, and
the file is still passed to the main reader.
readEarliestTimestampand its guard test are unchanged.Test
Adds "a single unprobeable file does not abort ordering the rest" to
src/test/claudeUsageFiles.test.ts: a >1 MiB no-timestampjournal.jsonlbeside a normal file. It asserts
readEarliestTimestampstill rejects on thejournal, and that
sortUsageFilesByEarliestTimestampresolves and returns bothfiles.
CHANGELOG.mdis updated.package.jsonversion is left unchanged perCONTRIBUTING.
谢谢