fix(data:export): properly handle big JSON exports #1140
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Updates bulk export utility to ensure it doesn't check if the JSON file where records will be written already exists.
For a few thousands of records, the API will still return all in one batch so NUTs were passing but if the job splits results in +1 batch then
data export bulk --result-format json
fails when trying to save the second batch because the FS flag instructs node to fail if the file already exists (which does, from the 1st batch that was saved).repro:
query
ScratchOrgInfo
records in our na40 hub, there are ~1.6M records that get split in ~8 batches:you should get
Error (EEXIST): EEXIST: file already exists, open 'data.json'
. With this fix you should get a valid json, check its length withjq length data.json
.What issues does this PR fix or reference?
forcedotcom/cli#3138
@W-17380350@