Skip to content

Large xlsx record downloads fail after the records are already loaded #2063

Description

@paustint

Describe the bug and steps to reproduce

Downloading query results as xlsx fails once the workbook gets large enough, and it fails only after the user has waited through the whole download and file build.

Seen in production on 2026-09-11: a user downloaded 171,932 records across 107 fields as xlsx and got RangeError: Invalid array length. It throws inside SheetJS while serializing the finished workbook, where a2s calls new Array on the output byte length.

This is the same family as an earlier report at 958,114 records across 10 fields, which threw RangeError: Invalid string length from the sheet XML join(""). Which limit gets hit first depends on how wide the data is, so there is no single row count that describes it.

Expected behavior

The user should be told before the export starts that the selection is too large for a local xlsx, and steered to CSV or to the server side download, rather than waiting for the build and then getting a generic failure.

What already works

The failure is caught. RecordDownloadModal shows "There was a problem preparing your file download. Try downloading as CSV or JSON." so nothing crashes and no data is lost. Per cell truncation over Excel's 32,767 character limit is also already handled.

Suggested fix

Add a proactive guard in libs/ui/src/lib/file-download-modal/RecordDownloadModal.tsx before the local xlsx branch. Estimating cells as records x fields is the obvious heuristic, though the real limit is bytes, so the threshold needs picking deliberately. A warning in the modal beside the format radio would cost the user nothing when they are under it.

Worth noting the separate Permission Manager export hit V8's ~8.4 million object property cap the same day, fixed in #2060 by switching to dense worksheets. This path already uses dense mode, so that fix does not apply here.

Browser and operating system:

Chrome 152, Windows 10. Release v10.18.0.

Filed from BetterStack error triage.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions