Skip to content

Commit

Permalink
fix(data:export): properly handle big JSON exports
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Dec 6, 2024
1 parent 41a0468 commit 66de715
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/bulkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ export async function exportRecords(

if (outputInfo.format === 'json') {
const jsonWritable = fs.createWriteStream(outputInfo.filePath, {
// Open file for reading and appending. The file is created if it does not exist but fails if the path exists.
// Open file for appending. The file is created if it does not exist.
// https://nodejs.org/api/fs.html#file-system-flags
flags: 'ax+',
flags: 'a', // append mode
});

const totalRecords = jobInfo.numberRecordsProcessed;
Expand Down Expand Up @@ -166,6 +166,8 @@ export async function exportRecords(
? [
Readable.from(res.body.slice(res.body.indexOf(EOL) + 1)),
fs.createWriteStream(outputInfo.filePath, {
// Open file for appending. The file is created if it does not exist.
// https://nodejs.org/api/fs.html#file-system-flags
flags: 'a', // append mode
}),
]
Expand Down

0 comments on commit 66de715

Please sign in to comment.