From 25b6473b4d3ac20dd1a88d125824e6d8bc6c48f9 Mon Sep 17 00:00:00 2001 From: Will Lo Date: Tue, 22 Apr 2025 12:31:36 -0700 Subject: [PATCH 1/3] short term mitigation for listAvailableProfiles throttling error --- packages/core/src/codewhisperer/commands/basicCommands.ts | 1 + packages/core/src/codewhisperer/region/regionProfileManager.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/packages/core/src/codewhisperer/commands/basicCommands.ts b/packages/core/src/codewhisperer/commands/basicCommands.ts index c2978b56568..c04564c65cd 100644 --- a/packages/core/src/codewhisperer/commands/basicCommands.ts +++ b/packages/core/src/codewhisperer/commands/basicCommands.ts @@ -608,6 +608,7 @@ const registerToolkitApiCallbackOnce = once(() => { const auth = Auth.instance auth.onDidChangeConnectionState(async (e) => { + console.log(e) if (_toolkitApi && 'declareConnection' in _toolkitApi) { const id = e.id const conn = await auth.getConnection({ id }) diff --git a/packages/core/src/codewhisperer/region/regionProfileManager.ts b/packages/core/src/codewhisperer/region/regionProfileManager.ts index 53c159efdb7..7572b0d8273 100644 --- a/packages/core/src/codewhisperer/region/regionProfileManager.ts +++ b/packages/core/src/codewhisperer/region/regionProfileManager.ts @@ -28,6 +28,8 @@ import { parse } from '@aws-sdk/util-arn-parser' import { isAwsError, ToolkitError } from '../../shared/errors' import { telemetry } from '../../shared/telemetry/telemetry' import { localize } from '../../shared/utilities/vsCodeUtils' +import { sleep } from '../../shared/utilities/timeoutUtils' +import { randomInt } from 'crypto' // TODO: is there a better way to manage all endpoint strings in one place? export const defaultServiceConfig: CodeWhispererConfig = { @@ -116,6 +118,7 @@ export class RegionProfileManager { return [] } const availableProfiles: RegionProfile[] = [] + await sleep(randomInt(1000, 3000)) for (const [region, endpoint] of endpoints.entries()) { const client = await this._createQClient(region, endpoint, conn as SsoConnection) const requester = async (request: CodeWhispererUserClient.ListAvailableProfilesRequest) => From b0835806ed19ea963d865d56646ca0518d8ba2d7 Mon Sep 17 00:00:00 2001 From: Will Lo Date: Tue, 22 Apr 2025 13:01:40 -0700 Subject: [PATCH 2/3] r --- packages/core/src/codewhisperer/commands/basicCommands.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/codewhisperer/commands/basicCommands.ts b/packages/core/src/codewhisperer/commands/basicCommands.ts index c04564c65cd..c2978b56568 100644 --- a/packages/core/src/codewhisperer/commands/basicCommands.ts +++ b/packages/core/src/codewhisperer/commands/basicCommands.ts @@ -608,7 +608,6 @@ const registerToolkitApiCallbackOnce = once(() => { const auth = Auth.instance auth.onDidChangeConnectionState(async (e) => { - console.log(e) if (_toolkitApi && 'declareConnection' in _toolkitApi) { const id = e.id const conn = await auth.getConnection({ id }) From f310429ca8a6c966c4827822a3fe4695d5613af7 Mon Sep 17 00:00:00 2001 From: Will Lo Date: Tue, 22 Apr 2025 13:56:52 -0700 Subject: [PATCH 3/3] a --- packages/core/src/codewhisperer/region/regionProfileManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/codewhisperer/region/regionProfileManager.ts b/packages/core/src/codewhisperer/region/regionProfileManager.ts index 7572b0d8273..7c378849628 100644 --- a/packages/core/src/codewhisperer/region/regionProfileManager.ts +++ b/packages/core/src/codewhisperer/region/regionProfileManager.ts @@ -118,7 +118,7 @@ export class RegionProfileManager { return [] } const availableProfiles: RegionProfile[] = [] - await sleep(randomInt(1000, 3000)) + await sleep(randomInt(0, 6000)) for (const [region, endpoint] of endpoints.entries()) { const client = await this._createQClient(region, endpoint, conn as SsoConnection) const requester = async (request: CodeWhispererUserClient.ListAvailableProfilesRequest) =>