Skip to content

Commit 8021f66

Browse files
authored
error handling in Lookup Objects action (#56)
1 parent 64e46b6 commit 8021f66

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.4.2 (November 18, 2022)
2+
* Improved error handling in `Lookup Objects` action
3+
14
## 2.4.1 (October 07, 2022)
25
* Fixed loop issue when records equal to `Size of Polling Page` and have same `LastModifiedDate` in `Get Updated Objects Polling` trigger
36
* Update Sailor version to 2.7.0

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Customer relationship management (CRM) software & cloud computing from the leader in CRM solutions for businesses large & small.",
44
"docsUrl": "https://github.com/elasticio/salesforce-component-v2",
55
"url": "http://www.salesforce.com/",
6-
"version": "2.4.1",
6+
"version": "2.4.2",
77
"authClientTypes": [
88
"oauth2"
99
],

lib/salesForceClient.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,26 @@ class SalesForceClient {
223223
const includeDeleted = options.includeDeleted || this.configuration.includeDeleted;
224224
const { wherePart, offset, limit } = options;
225225
try {
226-
await this.connection.sobject(sobject)
227-
.select('*')
228-
.where(wherePart)
229-
.offset(offset)
230-
.limit(limit)
231-
.scanAll(includeDeleted)
232-
.on('error', (err) => {
233-
this.logger.error('Salesforce returned an error');
234-
throw err;
235-
})
236-
.on('record', (record) => {
237-
records.push(record);
238-
})
239-
.on('end', () => {
240-
this.logger.debug('Found %s records', records.length);
241-
})
242-
.execute({ autoFetch: true, maxFetch: limit });
226+
await new Promise((resolve, reject) => {
227+
this.connection.sobject(sobject)
228+
.select('*')
229+
.where(wherePart)
230+
.offset(offset)
231+
.limit(limit)
232+
.scanAll(includeDeleted)
233+
.on('error', (err) => {
234+
this.logger.error('Salesforce returned an error');
235+
reject(err);
236+
})
237+
.on('record', (record) => {
238+
records.push(record);
239+
})
240+
.on('end', () => {
241+
this.logger.debug('Found %s records', records.length);
242+
resolve();
243+
})
244+
.execute({ autoFetch: true, maxFetch: limit });
245+
});
243246
} catch (e) {
244247
this.logger.error('Lookup query failed');
245248
throw e;

0 commit comments

Comments
 (0)