cd /news/ai-tools/how-i-built-a-200mb-streaming-jsonl-… · home › topics › ai-tools › article
[ARTICLE · art-178378] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

How I Built a 200MB Streaming JSONL Eval Diff Viewer for VS Code and Cursor With Zero Runtime Dependencies

A developer built EvalDiff v0.2.0, a read-only VS Code and Cursor extension that diffs large JSONL eval files (baseline vs. candidate) with zero third-party runtime dependencies. The extension streams files with Node's fs.createReadStream and readline under a 200MB file-size cap, an 8,000-character field cap and a 64MB memory circuit breaker, keeps filtering, search and sorting in the Extension Host, and renders results in a Webview with a nonce CSP and HTML escaping. It never opens source files for writing, with unit tests hashing inputs before and after to prove zero bytes changed.

recommendation

For large JSONL eval diffs, stream with readline under explicit file-size and buffered-byte caps, and escape every dynamic field behind a nonce CSP before rendering in a Webview.

more in playbook: Evals and testing for LLM apps
by read4 min views5 publishedNov 30, 2026

When you iterate on LLM prompts, RAG pipelines, or local model quantizations, your most important artifact is usually two boring .jsonl files: baseline.jsonl and candidate.jsonl.

Yet inspecting what actually regressed between those two files inside an editor is surprisingly painful:

fs.readFileSync() a 120MB JSONL file, JSON.parse() every row, and shove the entire array into webview.postMessage(). The renderer stalls or crashes.<script>alert("xss")</script> payloads in prompts and completions. Dropping raw eval text into an HTML report or Webview is an instant security bug. To solve this for my own workflow, I built EvalDiff (v0.2.0)—a 100% local, strictly read-only extension for Cursor, Windsurf, VSCodium, Antigravity, and VS Code with zero third-party runtime npm dependencies.

Here are the four concrete engineering patterns that made it fast, safe, and crash-proof.

Instead of buffering an entire file into memory, src/diffEngine.js uses only Node.js built-ins (fs.createReadStream and readline) with three explicit safety guards:

maxFileSizeMB, default 200MB) fs.promises.stat. maxFieldChars, default 8,000 chars) maxBufferedBytes, default 64MB)

const stream = fs.createReadStream(filePath, {
  encoding: 'utf8',
  highWaterMark: 64 * 1024
});
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });

try {
  for await (const line of rl) {
    totalLines += 1;
    const trimmed = line.trim();
    if (!trimmed) {
      blankLines += 1;
      continue;
    }

    let parsed;
    try {
      parsed = JSON.parse(trimmed);
    } catch (parseErr) {
      malformedCount += 1;
      malformedLines.push({
        lineNumber: totalLines,
        rawPreview: trimmed.slice(0, 160),
        error: parseErr.message
      });
      continue;
    }

    const normalized = normalizeRecord(parsed, totalLines, maxFieldChars);
    const recBytes = estimateRecordBytes(normalized);

    if (bufferedBytes + recBytes > maxBufferedBytes && records.length > 0) {
      truncated = true;
      truncationReason = 'MEMORY_LIMIT';
      break;
    }

    bufferedBytes += recBytes;
    records.push(normalized);
  }
} finally {
  rl.close();
  stream.destroy();
}

Notice two details:

finally block guarantees file descriptors are closed immediately if the memory circuit breaker trips. A common VS Code extension anti-pattern is sending the full parsed array to the Webview and filtering in browser JS. In EvalDiff, all filtering (status: regression | improvement | unchanged | added | removed), keyword search, sorting ( regressionFirst), and human review state stay inside the Extension Host.

The Webview only sends tiny query messages ({ status: 'regression', search: 'SELECT', page: 1 }) and receives:

summary object (< 2KB)50 cases by default) When the panel closes (panel.onDidDispose), the Extension Host drops its reference immediately so GC reclaims memory.

Unlike generic data tools that open local SQLite databases in read-write mode (risking WAL locks or file corruption), EvalDiff never opens source .jsonl files for writing. Our unit test suite verifies SHA-256 hashes of both input files before and after diffing to prove zero bytes changed.

Human Pass/Fail review annotations live separately in VS Code context.workspaceState, keyed by a SHA-1 hash of the file pair.

Meanwhile, both the Webview UI and exported standalone HTML audit reports lock down a strict nonce CSP (default-src 'none'; style-src 'unsafe-inline'; script-src 'nonce-...') and escape every dynamic field:

function escapeHtml(value) {
  if (value === null || value === undefined) return '';
  return String(value)
    .replace(/&/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    .replace(/"/g, '&quot;')
    .replace(/'/g, '&#39;');
}

AI teams rarely agree on JSONL column names. OpenAI Evals writes sample_id + messages + completion, Promptfoo often exports case_id + response + duration_ms, and custom Python scripts use score or boolean passed.

Instead of forcing users to write a YAML mapping config, normalizeRecord resolves common aliases in priority order—even flattening OpenAI messages arrays and summing usage.prompt_tokens + usage.completion_tokens when total_tokens is absent.

If you want framework-specific setup notes:

For monetization, I wanted an honest split that never compromises offline privacy:

.jsonl inspection, side-by-side diff up to 100 cases with KPI summary, malformed line diagnostics, local Pass/Fail review, and one-click Markdown PR summary copy. License activation uses Polar's public Customer Portal endpoint (POST /v1/customer-portal/license-keys/activate) with no private tokens in the extension—and it only fires when a user explicitly runs EvalDiff: Activate Pro License Key. After activation, the license state is cached in VS Code globalState, so everyday usage remains 100% offline.

git clone https://github.com/miaoduitw-creator/evaldiff-workbench.git
cd evaldiff-workbench
npm test

All 12 unit tests (streaming fault tolerance, read-only SHA-256 verification, regression math, OOM circuit breakers, XSS escaping, and mocked Polar license lifecycle) run on Node's built-in node:test runner with zero npm install step.

Or install directly from Open VSX for Cursor / Windsurf / VSCodium / Antigravity:

https://open-vsx.org/extension/miaodui/evaldiff-workbench

── more in #ai-tools 4 stories · sorted by recency
── more on @evaldiff 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-i-built-a-200mb-…] indexed:0 read:4min 2026-11-30 · —