From 66de7158f1f76c35075b01c1fd00989060165351 Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Fri, 6 Dec 2024 11:25:26 -0300 Subject: [PATCH] fix(data:export): properly handle big JSON exports --- src/bulkUtils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bulkUtils.ts b/src/bulkUtils.ts index b34bf1eb..ebc49825 100644 --- a/src/bulkUtils.ts +++ b/src/bulkUtils.ts @@ -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; @@ -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 }), ]