Skip to content

Commit d002f66

Browse files
committed
patch
1 parent f20470c commit d002f66

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

packages/core/src/codewhisperer/region/regionProfileManager.ts

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -285,35 +285,39 @@ export class RegionProfileManager {
285285
if (!previousSelected) {
286286
return
287287
}
288-
// Comment these out until we have a better way to deal with throttling issue, currently service can only take 1 tps
288+
289289
// cross-validation
290-
// this.getProfiles()
291-
// .then(async (profiles) => {
292-
// const r = profiles.find((it) => it.arn === previousSelected.arn)
293-
// if (!r) {
294-
// telemetry.amazonq_profileState.emit({
295-
// source: 'reload',
296-
// amazonQProfileRegion: 'not-set',
297-
// reason: 'profile could not be selected',
298-
// result: 'Failed',
299-
// })
300-
301-
// await this.invalidateProfile(previousSelected.arn)
302-
// RegionProfileManager.logger.warn(
303-
// `invlaidating ${previousSelected.name} profile, arn=${previousSelected.arn}`
304-
// )
305-
// }
306-
// })
307-
// .catch((e) => {
308-
// telemetry.amazonq_profileState.emit({
309-
// source: 'reload',
310-
// amazonQProfileRegion: 'not-set',
311-
// reason: (e as Error).message,
312-
// result: 'Failed',
313-
// })
314-
// })
315-
316-
await this.switchRegionProfile(previousSelected, 'reload')
290+
const jitterInSec = Math.floor(Math.random() * 6)
291+
const jitterInMs = jitterInSec * 1000
292+
setTimeout(async () => {
293+
this.getProfiles()
294+
.then(async (profiles) => {
295+
const r = profiles.find((it) => it.arn === previousSelected.arn)
296+
if (!r) {
297+
telemetry.amazonq_profileState.emit({
298+
source: 'reload',
299+
amazonQProfileRegion: 'not-set',
300+
reason: 'profile could not be selected',
301+
result: 'Failed',
302+
})
303+
304+
await this.invalidateProfile(previousSelected.arn)
305+
RegionProfileManager.logger.warn(
306+
`invlaidating ${previousSelected.name} profile, arn=${previousSelected.arn}`
307+
)
308+
}
309+
})
310+
.catch((e) => {
311+
telemetry.amazonq_profileState.emit({
312+
source: 'reload',
313+
amazonQProfileRegion: 'not-set',
314+
reason: (e as Error).message,
315+
result: 'Failed',
316+
})
317+
})
318+
319+
await this.switchRegionProfile(previousSelected, 'reload')
320+
}, jitterInMs)
317321
}
318322

319323
private loadPersistedRegionProfle(): { [label: string]: RegionProfile } {

0 commit comments

Comments
 (0)