Skip to content

Commit 8fb4ba8

Browse files
Add retries for LDAP
1 parent a81510d commit 8fb4ba8

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@
2525
"ts-node": "^10.9.1",
2626
"typescript": "^5.0.2"
2727
},
28-
"dependencies": {
28+
"dependencies": {
29+
"@octokit/auth-app": "4.0.13",
2930
"@octokit/plugin-throttling": "^5.0.1",
3031
"axios": "^1.4.0",
32+
"axios-retry": "^3.5.0",
3133
"dotenv": "^16.0.3",
3234
"express": "^4.18.2",
3335
"js-yaml": "^4.1.0",
3436
"ldap-escape": "^2.0.6",
3537
"ldapjs": "^3.0.1",
3638
"octokit": "^2.0.14",
3739
"openapi-backend": "^5.9.1",
38-
"swagger-ui-express": "^4.6.2",
39-
"@octokit/auth-app": "4.0.13"
40+
"swagger-ui-express": "^4.6.2"
4041
},
4142
"nodemonConfig": {
4243
"watch": [

src/services/ldapClient.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Config } from "../config";
22
import ldap from "ldapjs";
33
import ldapEscape from "ldap-escape";
44
import axios from "axios";
5+
import axiosRetry from "axios-retry";
56

67
const config = Config()
78

@@ -133,7 +134,12 @@ async function ForwardSearch(groupName: string) {
133134

134135
console.log(`Retrieving group (${groupName}) information from '${requestUrl}'`);
135136
try{
136-
const result = await axios.get(requestUrl);
137+
// TODO: do not directly use axios.create from within a function like this
138+
// it will cause a new client to be made per request.
139+
const client = axios.create();
140+
axiosRetry(client, { retries: 5 });
141+
142+
const result = await client.get(requestUrl);
137143
console.log(`Results for ${groupName}: ${result}`);
138144
return result.data as SearchAllResponse;
139145
}

0 commit comments

Comments
 (0)