Skip to content

Commit

Permalink
Merge pull request #1140 from salesforcecli/cd/bulk-export-json
Browse files Browse the repository at this point in the history
fix(data:export): properly handle big JSON exports
  • Loading branch information
shetzel authored Dec 6, 2024
2 parents 41a0468 + 66de715 commit 0e4d220
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 0e4d220

Please sign in to comment.