From bd549ddd8f69a08e7471c5698fd8cd1be694aab5 Mon Sep 17 00:00:00 2001 From: Emmanuel Evance Date: Tue, 19 Mar 2024 15:27:25 +0300 Subject: [PATCH] `salesforce` close bulk job when finish (#487) salesforce: await job.close() --- .changeset/config.json | 4 ++-- packages/salesforce/CHANGELOG.md | 6 ++++++ packages/salesforce/package.json | 2 +- packages/salesforce/src/Adaptor.js | 9 ++++----- pnpm-lock.yaml | 28 ---------------------------- 5 files changed, 13 insertions(+), 36 deletions(-) diff --git a/.changeset/config.json b/.changeset/config.json index 044f8d2f3..f94316e9c 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,5 +7,5 @@ "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", - "ignore": ["@openfn/language-template"] -} + "ignore": [] +} \ No newline at end of file diff --git a/packages/salesforce/CHANGELOG.md b/packages/salesforce/CHANGELOG.md index 5e9bdec11..9ea801cc2 100644 --- a/packages/salesforce/CHANGELOG.md +++ b/packages/salesforce/CHANGELOG.md @@ -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 diff --git a/packages/salesforce/package.json b/packages/salesforce/package.json index 0651d95fe..83540ffe7 100644 --- a/packages/salesforce/package.json +++ b/packages/salesforce/package.json @@ -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": { diff --git a/packages/salesforce/src/Adaptor.js b/packages/salesforce/src/Adaptor.js index 67fb2f0df..f23c0445c 100644 --- a/packages/salesforce/src/Adaptor.js +++ b/packages/salesforce/src/Adaptor.js @@ -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); }); @@ -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 => { @@ -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)); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 381fecd1c..41c0a0d89 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -626,34 +626,6 @@ importers: specifier: 3.0.2 version: 3.0.2 - packages/hello: - dependencies: - '@openfn/language-common': - specifier: workspace:* - version: link:../common - devDependencies: - assertion-error: - specifier: 2.0.0 - version: 2.0.0 - chai: - specifier: 4.3.6 - version: 4.3.6 - deep-eql: - specifier: 4.1.1 - version: 4.1.1 - esno: - specifier: ^0.16.3 - version: 0.16.3 - mocha: - specifier: 9.2.2 - version: 9.2.2 - rimraf: - specifier: 3.0.2 - version: 3.0.2 - undici: - specifier: ^5.22.1 - version: 5.23.0 - packages/hive: dependencies: '@openfn/language-common':