<timestamp>Thursday, Aug 13, 2026, 10:07 AM (UTC+2)</timestamp> Check if this issue is…
- User
Thursday, Aug 13, 2026, 10:07 AM (UTC+2)
Check if this issue is valid — if so, understand the root cause and fix it. At apps/frontend/src/lib/attachment-preview.ts, line 52:
For
.xlsx, this check only bounds compressed bytes;readWorkbookSheetsstill materializes every row beforetoSheettruncates it, so a highly compressible 10 MB workbook can freeze or exhaust the browser. Bound workbook parsing before materializing rows.- const isTabular = kind === 'table' || kind === 'workbook';
- if (isTabular && (await fetchAttachmentSize(path)) > MAX_TABULAR_PREVIEW_SIZE_MB * 1024 * 1024) {
-
code
return { kind: 'too-large' }; - } </file context>
- Assistant
I'll inspect the attachment preview flow and how workbooks are parsed so I can tell whether the size check actually protects the browser.
- Assistant
The size check only limits the compressed file. I'll inspect how
read-excel-fileparses sheets and whether we can stop before every row is materialized. - Assistant
The compressed-size check is real, but it still lets the parser expand every row. I'll look at how
read-excel-filebuilds sheets and whether we can stop after a row cap. - Assistant
The issue is valid: CSV already stops after
MAX_PREVIEW_ROWS, but xlsx still fully parses then slices. I'll cap each worksheet's XML to that row budget before the parser runs. - Assistant
The compressed-size check is real, but xlsx still fully expands every row. I'll cap each worksheet to the preview row budget before the parser runs, matching how CSV already stops early.
- Assistant
JSZip is choking on the Node
Blobfromwrite-excel-file. I'll feed it anArrayBufferinstead, which both the browser and tests handle reliably. - Assistant
The issue is valid. CSV already stops after
MAX_PREVIEW_ROWS; xlsx did not.The 10 MB check only looks at compressed bytes. An
.xlsxis a zip of XML, so a highly compressible workbook can still hold far more rows than that.readXlsxFilebuilt every row, and only then didtoSheetslice to 5000 — which is what could freeze the tab.Workbook sheets are now capped to
MAX_PREVIEW_ROWS + 1before the parser runs, the same+1pattern CSV already uses so the preview can still mark itself truncated.85:90:apps/frontend/src/lib/attachment-preview.tsconst readWorkbookSheets = async (blob: Blob): Promise<AttachmentSheet[]> => { const { default: readXlsxFile } = await import('read-excel-file/browser'); const sheets = await readXlsxFile(await capWorkbookForPreview(blob, MAX_PREVIEW_ROWS + 1)); return sheets.map(({ sheet, data }) => toSheet(sheet, data)); };