perf(export): stream large exports in bounded chunks instead of buffe… - #1290
Merged
RUKAYAT-CODER merged 1 commit intoAug 30, 2026
Merged
Conversation
…ring whole payload (rinafcode#1179)
|
@shogun444 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Thank you for contributing to the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1179
Why This PR Exists
Export serializers in
src/lib/export-scheduler/exporter.tspreviously built entire export payloads in memory as single monolithic strings before wrapping them into aBlob. Specifically:csvLines.join('\n')JSON.stringify(data.rows, null, 2)on full datasetsOn large datasets, this caused heavy memory spikes and$O(n^2)$ string reallocation overhead. This PR introduces bounded chunking primitives and incremental parts assembly to eliminate monolithic string concatenation while maintaining 100% byte-for-byte output parity.
What Changed
src/lib/export/utils.ts):ExportStreamOptionsinterface supporting configurablechunkSizeand per-chunk progress callbacks.createCSVSnapshotandcreateJSONSnapshotto yield bounded row batches.escapeCSVCell,escapeXml, andescapeHtml.src/lib/export-scheduler/exporter.ts):exportToCSVandexportToJSONto consume async generators and build the finalBlobfrom discrete chunks.exportToXLSXandexportToPDFto assemble from incremental parts arrays rather than repeated string concatenation.src/lib/export/utils.test.tscovering escaping, batch chunking, empty states, progress callbacks, and JSON pretty-print parity.src/lib/export-scheduler/__tests__/exporter.test.tswith aFileReader-basedreadBlobTexthelper to verify exact content equivalence rather than simpleinstanceof Blobchecks.Files Changed
src/lib/export/utils.tscreateCSVSnapshot,createJSONSnapshot,ExportStreamOptions, and escaping helperssrc/lib/export-scheduler/exporter.tsexportToCSV/exportToJSON; converted XLSX/PDF to incremental parts arrayssrc/lib/export/utils.test.tssrc/lib/export-scheduler/__tests__/exporter.test.tsType of Change
Test Evidence
Local Verification
prettier --checkpasses cleanly across all changed filesnpm run type-checkpasses with 0 errorsnpm run lintpasses with 0 warnings/errorsnpm run buildcompiled successfully (72 static pages generated)