Skip to content

Commit 2f3e2f4

Browse files
committed
fix(identity): avoid mutating fallback map during iteration
1 parent 0552fbf commit 2f3e2f4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,11 +909,15 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
909909
}
910910
}
911911

912+
const fallbackAccountIdsToDelete: string[] = [];
912913
for (const [accountId, fallbackIndex] of entry.fallbackByAccountId) {
913914
if (collapseFallbackIndex(fallbackIndex)) {
914-
entry.fallbackByAccountId.delete(accountId);
915+
fallbackAccountIdsToDelete.push(accountId);
915916
}
916917
}
918+
for (const accountId of fallbackAccountIdsToDelete) {
919+
entry.fallbackByAccountId.delete(accountId);
920+
}
917921
};
918922

919923
for (let i = 0; i < accounts.length; i += 1) {

0 commit comments

Comments
 (0)