Skip to content

Commit ffee521

Browse files
authored
Retry (#39)
* Implemented reconnect logic on errors * Update Sailor version to 2.6.27 * Get rid of vulnerabilities in dependencies * Add component pusher job to Circle.ci config
1 parent a47e0e7 commit ffee521

File tree

10 files changed

+620
-900
lines changed

10 files changed

+620
-900
lines changed

.circleci/config.yml

Lines changed: 116 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,125 @@
1-
version: 2
1+
version: 2.1
2+
parameters:
3+
node-version:
4+
type: string
5+
default: "16.13.2"
6+
orbs:
7+
node: circleci/node@5.0.0
8+
slack: circleci/slack@4.5.3
9+
commands:
10+
notify_on_failure:
11+
steps:
12+
- slack/notify:
13+
event: fail
14+
custom: |
15+
{
16+
"blocks": [
17+
{
18+
"type": "section",
19+
"fields": [
20+
{
21+
"type": "mrkdwn",
22+
"text": ":red_circle: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* build failed"
23+
}
24+
]
25+
},
26+
{
27+
"type": "actions",
28+
"elements": [
29+
{
30+
"type": "button",
31+
"text": {
32+
"type": "plain_text",
33+
"text": "View Job"
34+
},
35+
"url": "${CIRCLE_BUILD_URL}"
36+
}
37+
]
38+
}
39+
]
40+
}
41+
notify_on_pass:
42+
steps:
43+
- slack/notify:
44+
event: pass
45+
custom: |
46+
{
47+
"blocks": [
48+
{
49+
"type": "section",
50+
"fields": [
51+
{
52+
"type": "mrkdwn",
53+
"text": ":tada: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* was successfully built and published"
54+
}
55+
]
56+
},
57+
{
58+
"type": "actions",
59+
"elements": [
60+
{
61+
"type": "button",
62+
"text": {
63+
"type": "plain_text",
64+
"text": "View Job"
65+
},
66+
"url": "${CIRCLE_BUILD_URL}"
67+
}
68+
]
69+
}
70+
]
71+
}
272
jobs:
373
test:
4-
docker:
5-
- image: circleci/node:12-stretch
74+
docker: # run the steps with Docker
75+
- image: cimg/base:stable
676
steps:
777
- checkout
8-
- restore_cache:
9-
key: dependency-cache-{{ checksum "package.json" }}
78+
- node/install:
79+
node-version: << pipeline.parameters.node-version >>
80+
- node/install-packages:
81+
cache-path: ./node_modules
82+
override-ci-command: npm install
1083
- run:
11-
name: Installing Dependencies
12-
command: npm install
13-
- save_cache:
14-
key: dependency-cache-{{ checksum "package.json" }}
15-
paths:
16-
- node_modules
84+
name: Audit Dependencies
85+
command: npm audit --production --audit-level=high
1786
- run:
18-
name: Running Mocha Tests
87+
name: test
1988
command: npm test
89+
build:
90+
docker:
91+
- image: cimg/base:stable
92+
user: root
93+
steps:
94+
- checkout
95+
- node/install:
96+
node-version: << pipeline.parameters.node-version >>
97+
- setup_remote_docker:
98+
version: 19.03.13
99+
docker_layer_caching: true
100+
# build and push Docker image
101+
- run:
102+
name: Install component-build-helper lib
103+
command: npm install -g @elastic.io/component-build-helper
104+
- run:
105+
name: Build and publish docker image
106+
command: build_component_docker
107+
- notify_on_failure
108+
- notify_on_pass
20109
workflows:
21-
version: 2
22-
build_and_test:
110+
test:
111+
jobs:
112+
- test:
113+
name: "Running tests"
114+
filters:
115+
tags:
116+
ignore: /.*/
117+
publish_release:
23118
jobs:
24-
- test
119+
- build:
120+
name: "Build and publish docker image"
121+
filters:
122+
branches:
123+
ignore: /.*/
124+
tags:
125+
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2.2.2 (April 08, 2022)
2+
* Implemented reconnect logic on errors
3+
* Update Sailor version to 2.6.27
4+
* Get rid of vulnerabilities in dependencies
5+
* Add component pusher job to Circle.ci config
6+
7+
18
## 2.2.1 (December 1, 2021)
29

310
* Upgrade sailor version to 2.6.26

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"title": "Salesforce v2",
3-
"version": "2.2.1",
43
"description": "Customer relationship management (CRM) software & cloud computing from the leader in CRM solutions for businesses large & small.",
54
"docsUrl": "https://github.com/elasticio/salesforce-component-v2",
65
"url": "http://www.salesforce.com/",
76
"buildType": "docker",
7+
"version": "2.2.2",
88
"authClientTypes": ["oauth2"],
99
"envVars": {
1010
"SALESFORCE_API_VERSION": {

lib/helpers/wrapper.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exports.callJSForceMethod = async function callJSForceMethod(configuration, meth
2323
let result;
2424
let isSuccess = false;
2525
let iteration = REFRESH_TOKEN_RETRIES;
26+
let retry = true;
2627
do {
2728
iteration -= 1;
2829
try {
@@ -43,7 +44,7 @@ exports.callJSForceMethod = async function callJSForceMethod(configuration, meth
4344
this.logger.debug('Method %s was successfully executed', method);
4445
break;
4546
} catch (e) {
46-
this.logger.error('Got error %s', e.name || '');
47+
this.logger.error(`Got error ${e.name} - ${e.message}`);
4748
if (e.name === 'INVALID_SESSION_ID') {
4849
try {
4950
this.logger.debug('Session is expired, trying to refresh token...');
@@ -53,6 +54,9 @@ exports.callJSForceMethod = async function callJSForceMethod(configuration, meth
5354
} catch (err) {
5455
this.logger.error('Failed to refresh token');
5556
}
57+
} else if (retry) {
58+
client = undefined;
59+
retry = false;
5660
} else {
5761
throw e;
5862
}

0 commit comments

Comments
 (0)