Skip to content

Commit

Permalink
salesforce close bulk job when finish (#487)
Browse files Browse the repository at this point in the history
salesforce: await job.close()
  • Loading branch information
mtuchi committed Mar 19, 2024
1 parent 026505b commit bd549dd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["@openfn/language-template"]
}
"ignore": []
}
6 changes: 6 additions & 0 deletions packages/salesforce/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/language-salesforce

## 4.5.2

### Patch Changes

- 2006e88: fix an issue with bulk jobs not closing

## 4.5.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-salesforce",
"version": "4.5.1",
"version": "4.5.2",
"description": "Salesforce Language Pack for OpenFn",
"homepage": "https://docs.openfn.org",
"exports": {
Expand Down
9 changes: 4 additions & 5 deletions packages/salesforce/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ export function bulk(sObject, operation, options, records) {
console.info('Executing batch.');
batch.execute(chunkedBatch);

batch.on('error', function (err) {
job.close();
batch.on('error', async function (err) {
await job.close();
console.error('Request error:');
reject(err);
});
Expand All @@ -379,8 +379,8 @@ export function bulk(sObject, operation, options, records) {
var batch = job.batch(batchId);
batch.poll(interval, timeout);
})
.then(res => {
job.close();
.then(async res => {
await job.close();
const errors = res
.map((r, i) => ({ ...r, position: i + 1 }))
.filter(item => {
Expand All @@ -394,7 +394,6 @@ export function bulk(sObject, operation, options, records) {

if (failOnError && errors.length > 0) {
console.error('Errors detected:');

reject(JSON.stringify(errors, null, 2));
} else {
console.log('Result : ' + JSON.stringify(res, null, 2));
Expand Down
28 changes: 0 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bd549dd

Please sign in to comment.