chore: snapshot main sync

This commit is contained in:
2026-06-17 20:08:31 +00:00
parent b18de2a331
commit 8bd32537cf
354 changed files with 10208 additions and 9230 deletions

View File

@@ -141,8 +141,10 @@ export function trimCapture(captureJson: string | null, sizeKB: number): string
if (!captureJson) return null;
const sizeBytes = Buffer.byteLength(captureJson, 'utf8');
if (sizeBytes <= sizeKB * 1024) return captureJson;
// Trim the capture to fit within the cap.
return captureJson.slice(0, Math.floor(sizeKB * 1024));
// Trim by BYTES, not JS chars: a char-index slice can split a multi-byte
// codepoint and emit invalid UTF-8 (DB write error / corruption). Buffer
// subarray + toString('utf8') truncates at the last whole codepoint.
return Buffer.from(captureJson, 'utf8').subarray(0, Math.floor(sizeKB * 1024)).toString('utf8');
}
/**