Bug Summary
The export worker in apps/consumer/src/workers/export.worker.js opens a MongoDB cursor over the entire requested collection and streams every document to storage without any limit on the number of documents processed:
const cursor = Model.find().lean().cursor();
for await (const doc of cursor) {
// streams every document, no count cap
}
The dbExportHandler controller enforces a per-project daily export quota (1 export/day for free, 5 for pro), but it does not cap the size of the collection being exported. A project that has accumulated millions of documents can trigger an export job that:
- Holds a MongoDB cursor open for a prolonged period, consuming a connection from the pool.
- Writes gigabytes of JSON to the storage backend (Supabase or external S3-compatible).
- Keeps the BullMQ worker occupied indefinitely, blocking other queued export jobs from executing.
- Generates a presigned download URL for a potentially multi-gigabyte file delivered via email.
There is no MAX_EXPORT_ROWS constant, no .limit() call, and no streaming byte-count guard in either the controller or the worker.
Expected Behavior
The export worker should enforce a maximum document count (for example, 100,000 documents) or a maximum byte limit on the streamed JSON payload. When the limit is reached, the export should either stop and note the truncation, or reject the job and return an informative error to the user.
Actual Behavior
All documents in the collection are exported with no count or size ceiling.
Affected File
apps/consumer/src/workers/export.worker.js, the cursor iteration loop.
@geturbackend I would like to work on this issue. Could you please assign/ it to me? Contributing under NSoC '26.
Bug Summary
The export worker in
apps/consumer/src/workers/export.worker.jsopens a MongoDB cursor over the entire requested collection and streams every document to storage without any limit on the number of documents processed:The
dbExportHandlercontroller enforces a per-project daily export quota (1 export/day for free, 5 for pro), but it does not cap the size of the collection being exported. A project that has accumulated millions of documents can trigger an export job that:There is no
MAX_EXPORT_ROWSconstant, no.limit()call, and no streaming byte-count guard in either the controller or the worker.Expected Behavior
The export worker should enforce a maximum document count (for example, 100,000 documents) or a maximum byte limit on the streamed JSON payload. When the limit is reached, the export should either stop and note the truncation, or reject the job and return an informative error to the user.
Actual Behavior
All documents in the collection are exported with no count or size ceiling.
Affected File
apps/consumer/src/workers/export.worker.js, thecursoriteration loop.@geturbackend I would like to work on this issue. Could you please assign/ it to me? Contributing under NSoC '26.