Skip to content

fix(server): bound usage transcript lines - #7265

Open
ifBars wants to merge 1 commit into
pingdotgg:mainfrom
ifBars:agent/bound-usage-transcript-lines
Open

fix(server): bound usage transcript lines#7265
ifBars wants to merge 1 commit into
pingdotgg:mainfrom
ifBars:agent/bound-usage-transcript-lines

Conversation

@ifBars

@ifBars ifBars commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace readline with a byte-bounded JSONL reader for usage transcripts
  • discard any record over 64 MiB and resume scanning at the next newline
  • cover oversized records, continued usage extraction, CRLF input, and an unterminated final record

Why

A Codex rollout can contain a very large tool or patch event on one JSONL line. Node's readline constructs the entire line before yielding it, so a line above V8's string limit throws RangeError: Invalid string length from the stream callback and terminates the T3 server when Usage is opened.

The new reader retains at most 64 MiB for a record. Once a record crosses that limit, it drains bytes through the next newline without decoding them, then continues processing later usage records normally.

Validation

  • vp test run apps/server/src/usage: 40 tests passed
  • targeted lint and formatting checks pass
  • reproduced the original Node crash with an untouched 525.98 MiB rollout containing one 516.47 MiB line
  • patched reader completed that rollout in 443 ms with 651 usage records and about 142 MiB peak RSS
  • extracted records exactly matched a control copy with only the oversized non-usage event removed
  • scanned 1.56 GB of active 90-day transcripts in 4.96 s and 688 MB of archived transcripts in 2.24 s, with no failed files

Fixes #7258.

Implemented with GPT-5.6 Sol via Codex.

Note

Bound per-line bytes in readTranscriptRecords to skip oversized JSONL records

  • Replaces node:readline with a new readBoundedLines async generator in usageTranscriptReader.ts that accumulates file bytes until a newline, discarding lines that exceed a configurable byte limit before constructing a string.
  • Defaults to 64 MiB per line (DEFAULT_MAX_LINE_BYTES), which is well below V8's max string length but above expected valid transcript records.
  • Callers can override the limit via the new optional TranscriptReadOptions.maxLineBytes parameter on readTranscriptRecords.
  • Also adds CRLF support (trims trailing \r) and yields unterminated final lines.
  • Behavioral Change: oversized lines (e.g. large tool results) are now silently skipped rather than causing a potential OOM or parse error.

Macroscope summarized 42f1b50.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c27bcfd-dbf1-4813-a7fc-35322c68a3d7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 16, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 42f1b50

Defensive bug fix replacing Node's readline with a bounded reader to prevent V8 crashes from oversized transcript lines. The change is self-contained with comprehensive tests and a conservative 64MB default limit.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage scan crashes server on oversized Codex JSONL record

1 participant