Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
fix: restore salesloft retry config (#1986)
Browse files Browse the repository at this point in the history
This was removed in #1938 for some reason
  • Loading branch information
lucasmarshall authored Nov 28, 2023
1 parent 0f0b03e commit 4aa8fba
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions packages/core/remotes/impl/salesloft/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,30 @@ class SalesloftClient extends AbstractEngagementRemoteClient {
heartbeat?: () => void
): (next?: string) => Promise<SalesloftPaginatedRecords> {
return async (next?: string) => {
return await retryWhenAxiosRateLimited(async () => {
if (heartbeat) {
heartbeat();
}
await this.maybeRefreshAccessToken();
const response = await axios.get<SalesloftPaginatedRecords>(endpoint, {
params: updatedAfter
? {
...DEFAULT_LIST_PARAMS,
...getUpdatedAfterPathParam(updatedAfter),
page: next ? parseInt(next) : undefined,
}
: {
...DEFAULT_LIST_PARAMS,
page: next ? parseInt(next) : undefined,
},
headers: this.#headers,
});
return response.data;
});
return await retryWhenAxiosRateLimited(
async () => {
if (heartbeat) {
heartbeat();
}
await this.maybeRefreshAccessToken();
const response = await axios.get<SalesloftPaginatedRecords>(endpoint, {
params: updatedAfter
? {
...DEFAULT_LIST_PARAMS,
...getUpdatedAfterPathParam(updatedAfter),
page: next ? parseInt(next) : undefined,
}
: {
...DEFAULT_LIST_PARAMS,
page: next ? parseInt(next) : undefined,
},
headers: this.#headers,
});
return response.data;
},
// the rate limit is 600/minute shared among all users of the API, so we should wait longer than the usual 1s just to be safe
{ retries: 3, minTimeout: 10_000, maxTimeout: 60_000, factor: 3, randomize: true }
);
};
}

Expand Down

0 comments on commit 4aa8fba

Please sign in to comment.