Skip to content

Commit

Permalink
fix: ingest job doesn't properly validate chunkDataSize causing it …
Browse files Browse the repository at this point in the history
…to exceeds the API limit
  • Loading branch information
Codeneos committed Dec 28, 2023
1 parent 48db006 commit 074dfe2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/salesforce/src/bulk/bulkIngestJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,16 @@ export class BulkIngestJob<TRecord extends object = any> extends BulkJob<IngestJ
for (const item of data) {
const row = columns.map(c => this.encodeValue(item[c])).join(this.delimiterCharacter) + this.lineEndingCharacters;
const encodedRow = Buffer.from(row, this.encoding);
encodedData.push(encodedRow);

if (encodedDataSize + encodedRow.byteLength > this.chunkDataSize) {
if (encodedData.length > 1 && (encodedDataSize + encodedRow.byteLength) > this.chunkDataSize) {
const chunk = Buffer.concat(encodedData);
encodedData = [ encodedHeader ];
encodedDataSize = encodedHeader.byteLength;
yield chunk;
}

encodedData.push(encodedRow);
encodedDataSize += encodedRow.byteLength;
}

if (encodedData.length > 1) {
Expand Down

0 comments on commit 074dfe2

Please sign in to comment.