Premature Completion in Data Export Batch
Level 2 · node · Concurrency · Promise handling error
Scenario
An administrative data-export batch asynchronously generates and stores CSV fragments for multiple accounts, then marks the job as completed. Each fragment eventually succeeds, but immediately after the completion response the result list can be missing some or all files, which appear only shortly afterward. The worker, exporter, file repository, and job repository are separated.
Requirements
- A batch job may become completed only after every account export file has been stored - The completed result fileCount must match the number of files actually stored - A job with no accountIds may complete with zero files - Each accountId must be exported exactly once - When runExportBatch resolves, its result files must be immediately queryable
Acceptance criteria
- A single-account batch has one stored file and fileCount 1 when the call returns
- A multi-account batch has all account files stored when the call returns
- The completed job fileCount matches the actual repository file count
- An empty account list creates no files and returns completed with fileCount 0
- For multiple accounts the exporter is called exactly once per accountId