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
- Connect to a ClickHouse database
- Open a table (or run a SELECT) returning ~500,000 rows
- Right click the results grid → Export → All Data → Format: Excel
- Choose a destination and click Save
- 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
Bug Description
Exporting a large result set (~500,000 rows) fails with
Export failed: Invalid string length.Invalid string lengthis a V8RangeError, raised when a JavaScript string exceeds the engine'smaximum 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
Export failed: Invalid string lengthExpected 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 lengthand no file is produced.Additional findings:
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 Limithas no effect —All Datare-runs the query and ignores it.Suggested fix: write rows to a
fs.createWriteStreamin batches rather than building one string.For CSV/JSON this is straightforward; for XLSX a streaming writer (e.g.
exceljsWorkbookWriterin streaming mode) would avoid the same ceiling. Note XLSX also has a hard1,048,576-row-per-sheet limit, so sheet splitting may be needed for very large Excel exports.
Environment
Error Messages