Skip to content
This repository has been archived by the owner on Jul 31, 2021. It is now read-only.

Commit

Permalink
Improve deployment stability (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
adon authored Apr 15, 2020
1 parent 687d8b3 commit 6e269f6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/auth0/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { PromisePoolExecutor } from 'promise-pool-executor';
import { flatten } from '../utils';

const API_CONCURRENCY = 3;
// To ensure a complete deployment, limit the API requests generated to be 80% of the capacity
// https://auth0.com/docs/policies/rate-limits#management-api-v2
const API_FREQUENCY_PER_SECOND = 8;

function getEntity(rsp) {
const found = Object.values(rsp).filter(a => Array.isArray(a));
Expand All @@ -14,7 +17,9 @@ function getEntity(rsp) {
// Warp around the ManagementClient and detect when requesting specific pages to return all
export default function pagedClient(client) {
client.pool = new PromisePoolExecutor({
concurrencyLimit: API_CONCURRENCY
concurrencyLimit: API_CONCURRENCY,
frequencyLimit: API_FREQUENCY_PER_SECOND,
frequencyWindow: 1000 // 1 sec
});

return new Proxy(client, {
Expand Down

0 comments on commit 6e269f6

Please sign in to comment.