@@ -285,34 +285,40 @@ export class RegionProfileManager {
285
285
if ( ! previousSelected ) {
286
286
return
287
287
}
288
+
289
+ await this . switchRegionProfile ( previousSelected , 'reload' )
290
+
288
291
// cross-validation
289
- this . getProfiles ( )
290
- . then ( async ( profiles ) => {
291
- const r = profiles . find ( ( it ) => it . arn === previousSelected . arn )
292
- if ( ! r ) {
292
+ // jitter of 0 ~ 5 second
293
+ const jitterInSec = Math . floor ( Math . random ( ) * 6 )
294
+ const jitterInMs = jitterInSec * 1000
295
+ setTimeout ( async ( ) => {
296
+ this . getProfiles ( )
297
+ . then ( async ( profiles ) => {
298
+ const r = profiles . find ( ( it ) => it . arn === previousSelected . arn )
299
+ if ( ! r ) {
300
+ telemetry . amazonq_profileState . emit ( {
301
+ source : 'reload' ,
302
+ amazonQProfileRegion : 'not-set' ,
303
+ reason : 'profile could not be selected' ,
304
+ result : 'Failed' ,
305
+ } )
306
+
307
+ await this . invalidateProfile ( previousSelected . arn )
308
+ RegionProfileManager . logger . warn (
309
+ `invlaidating ${ previousSelected . name } profile, arn=${ previousSelected . arn } `
310
+ )
311
+ }
312
+ } )
313
+ . catch ( ( e ) => {
293
314
telemetry . amazonq_profileState . emit ( {
294
315
source : 'reload' ,
295
316
amazonQProfileRegion : 'not-set' ,
296
- reason : 'profile could not be selected' ,
317
+ reason : ( e as Error ) . message ,
297
318
result : 'Failed' ,
298
319
} )
299
-
300
- await this . invalidateProfile ( previousSelected . arn )
301
- RegionProfileManager . logger . warn (
302
- `invlaidating ${ previousSelected . name } profile, arn=${ previousSelected . arn } `
303
- )
304
- }
305
- } )
306
- . catch ( ( e ) => {
307
- telemetry . amazonq_profileState . emit ( {
308
- source : 'reload' ,
309
- amazonQProfileRegion : 'not-set' ,
310
- reason : ( e as Error ) . message ,
311
- result : 'Failed' ,
312
320
} )
313
- } )
314
-
315
- await this . switchRegionProfile ( previousSelected , 'reload' )
321
+ } , jitterInMs )
316
322
}
317
323
318
324
private loadPersistedRegionProfle ( ) : { [ label : string ] : RegionProfile } {
0 commit comments