From 4c9a557533a7f55acaa375c706f368471510a149 Mon Sep 17 00:00:00 2001 From: Marvinthebored Date: Sun, 3 May 2026 11:01:41 +0800 Subject: [PATCH] fix(gateway): skip oversized JSONL lines to prevent event-loop starvation Large transcript JSONL records (multi-MB tool results, file content) block the event loop via JSON.parse before truncation logic can skip them. Add a 256 KiB line-size guard to parseTailTranscriptRecord and extractUsageSnapshotFromTranscriptLine, and replace the full transcript index scan in readSessionTitleFieldsFromTranscriptAsync with the existing bounded sync reader. Observed improvement on a production install (33 sessions): chat.history dropped from 13-16s to ~1.2s, event loop utilization from 0.999 to normal, steady-state CPU from ~100% to 0.2-0.3%. Co-Authored-By: Claude Opus 4.6