Skip to content

Export fails with "Invalid string length" on large result sets (V8 max string limit) #1188

Description

@hamedelbhrawy

Bug Description

Exporting a large result set (~500,000 rows) fails with Export failed: Invalid string length.

Invalid string length is a V8 RangeError, raised when a JavaScript string exceeds the engine's
maximum length (~512MB / ~2^29 characters). This suggests the exporter concatenates the entire
output file into a single in-memory string before writing it to disk, instead of streaming.

Because this is a hard V8 limit, it cannot be worked around by the user — no amount of RAM or
configuration helps. Exports above a certain output size are simply impossible.

Repro steps

  1. Connect to a ClickHouse database
  2. Open a table (or run a SELECT) returning ~500,000 rows
  3. Right click the results grid → Export → All Data → Format: Excel
  4. Choose a destination and click Save
  5. See error notification: Export failed: Invalid string length

Expected Behavior

The export completes and writes the file to disk regardless of row count. Output size should be
bounded by available disk space, not by process memory or the V8 maximum string length.

Actual Behavior

The export fails with Export failed: Invalid string length and no file is produced.

Additional findings:

  • The same failure occurs with CSV format, so it is not specific to XLSX generation.
  • Export from Query (editor title bar / DBCode: Export Query Results) fails identically,
    so the problem appears to be in a shared serialization path rather than in the grid.
  • Dbcode: Query Row Limit has no effect — All Data re-runs the query and ignores it.

Suggested fix: write rows to a fs.createWriteStream in batches rather than building one string.
For CSV/JSON this is straightforward; for XLSX a streaming writer (e.g. exceljs
WorkbookWriter in streaming mode) would avoid the same ceiling. Note XLSX also has a hard
1,048,576-row-per-sheet limit, so sheet splitting may be needed for very large Excel exports.

Environment

  • DBCode version: 1.36.5
  • VS Code (or fork) version: <fill in — Code > About>
  • OS: macOS
  • Database: ClickHouse
  • Connection: <direct / SSH / SSL>

Error Messages

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions