mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
The board export routes buffered the entire board in memory before sending: JSON export built one object with every card, comment, activity, checklist and base64 attachment; CSV called that same build(); Excel additionally loaded data it never renders (activities/checklists/subtasks/rules) and did O(n^2) result.cards.find() lookups. On big boards this peaked at gigabytes and could exceed V8's max string length. Now: - Exporter.buildStream(res) writes the JSON document straight to the response a document at a time from raw Mongo cursors, encoding each attachment file to base64 in 3-byte-aligned chunks. Same _format/keys, so import round-trips. - Exporter.buildCsvStream(res) keeps only the small lookup tables in memory and streams cards from a cursor, writing one CSV/TSV row at a time. - ExporterExcel uses the exceljs streaming WorkbookWriter, committing each row to the response, drops the unused collections, and resolves parent/comment card titles via an id->title map instead of scanning all cards. Peak memory stays flat regardless of board size.