Skip to content
Merged
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
11 changes: 8 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,12 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
if (accountsToHydrate.length === 0) return storage;

let changed = false;
await Promise.all(
accountsToHydrate.map(async (account) => {
// process in chunks of 3 to avoid auth0 rate limits (429) on startup
const chunkSize = 3;
for (let i = 0; i < accountsToHydrate.length; i += chunkSize) {
const chunk = accountsToHydrate.slice(i, i + chunkSize);
await Promise.all(
chunk.map(async (account) => {
try {
const refreshed = await queuedRefresh(account.refreshToken);
if (refreshed.type !== "success") return;
Expand Down Expand Up @@ -721,8 +725,9 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
} catch {
logWarn(`[${PLUGIN_NAME}] Failed to hydrate email for account`);
}
}),
})
);
}

if (changed) {
storage.accounts = accountsCopy;
Expand Down