fix: respect maxRetries
This commit is contained in:
parent
4247306204
commit
94d32b6aeb
1 changed files with 14 additions and 2 deletions
|
|
@ -156,16 +156,22 @@ export class ControlPlaneClient {
|
|||
// take effect. Otherwise the organization(s) won't show up.
|
||||
// This error manifests as a 404 (user not found)
|
||||
let retries = 0;
|
||||
const maxRetries = 5;
|
||||
const maxRetries = 10;
|
||||
const maxWaitTime = 20000; // 20 seconds in milliseconds
|
||||
|
||||
while (true) {
|
||||
while (retries < maxRetries) {
|
||||
const resp = await this.request("ide/list-organizations", {
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
if (resp.status === 404) {
|
||||
retries++;
|
||||
if (retries >= maxRetries) {
|
||||
console.warn(
|
||||
`Failed to list organizations after ${maxRetries} retries: user not found`,
|
||||
);
|
||||
return [];
|
||||
}
|
||||
const waitTime = Math.min(
|
||||
Math.pow(2, retries) * 100,
|
||||
maxWaitTime / maxRetries,
|
||||
|
|
@ -181,6 +187,12 @@ export class ControlPlaneClient {
|
|||
const { organizations } = (await resp.json()) as any;
|
||||
return organizations;
|
||||
}
|
||||
|
||||
// This should never be reached due to the while condition, but adding for safety
|
||||
console.warn(
|
||||
`Failed to list organizations after ${maxRetries} retries: maximum attempts exceeded`,
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
public async listAssistantFullSlugs(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue