Skip to content

fix: flow and forms request throttling #1133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/tools/auth0/handlers/flowVaultConnections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export default class FlowVaultHandler extends DefaultHandler {
});
}

objString(item): string {
return super.objString({ id: item.id, name: item.name });
}

async getType(): Promise<Asset> {
if (this.existing) {
return this.existing;
Expand Down
30 changes: 23 additions & 7 deletions src/tools/auth0/handlers/flows.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import _, { isArray } from 'lodash';
import { isArray, isEmpty } from 'lodash';
import {
GetFlows200ResponseOneOfInner,
GetFlowsVaultConnections200ResponseOneOfInner,
PostFlows201Response,
} from 'auth0';
import dotProp from 'dot-prop';
import DefaultHandler, { order } from './default';
Expand Down Expand Up @@ -41,6 +42,25 @@ export default class FlowHandler extends DefaultHandler {
});
}

objString(item): string {
return super.objString({ id: item.id, name: item.name });
}

async getFlows(flows: Array<GetFlows200ResponseOneOfInner>): Promise<PostFlows201Response[]> {
const allFlows = await this.client.pool
.addEachTask({
data: flows,
generator: ({ id }) =>
this.client.flows.get({ id: id }).then((response) => {
if (isEmpty(response?.data)) return null;
return response.data;
}),
})
.promise();

return allFlows.filter((flow): flow is PostFlows201Response => flow !== null);
}

async getType(): Promise<Asset> {
if (this.existing) {
return this.existing;
Expand All @@ -54,12 +74,8 @@ export default class FlowHandler extends DefaultHandler {
this.getAllFlowConnections(),
]);

const allFlows = await Promise.all(
flows.map(async (f) => {
const { data: flow } = await this.client.flows.get({ id: f.id });
return flow;
})
);
// get more details for each flows
const allFlows: Array<PostFlows201Response> = await this.getFlows(flows);

// create a map for id to name from allFlowConnections
const connectionIdMap = {};
Expand Down
26 changes: 20 additions & 6 deletions src/tools/auth0/handlers/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
PostForms201Response,
} from 'auth0';
import dotProp from 'dot-prop';
import { isEmpty } from 'lodash';
import DefaultHandler, { order } from './default';
import log from '../../../logger';
import { Asset, Assets, CalculatedChanges } from '../../../types';
Expand Down Expand Up @@ -43,6 +44,24 @@ export default class FormsHandler extends DefaultHandler {
});
}

objString(item): string {
return super.objString({ id: item.id, name: item.name });
}

async getForms(forms: Array<PostForms201Response>): Promise<PostForms201Response[]> {
const allForms = await this.client.pool
.addEachTask({
data: forms,
generator: ({ id }) =>
this.client.forms.get({ id: id }).then((response) => {
if (isEmpty(response?.data)) return null;
return response.data;
}),
})
.promise();
return allForms.filter((form): form is PostForms201Response => form !== null);
}

async getType(): Promise<Asset> {
if (this.existing) {
return this.existing;
Expand All @@ -60,12 +79,7 @@ export default class FormsHandler extends DefaultHandler {
]);

// get more details for each form
const allForms = await Promise.all(
forms.map(async (from) => {
const { data: form } = await this.client.forms.get({ id: from.id });
return form;
})
);
const allForms = await this.getForms(forms);

// create a map for id to name from allFlows
const flowIdMap = {};
Expand Down