@@ -235,36 +235,37 @@ export class RegionProfileManager {
235
235
return
236
236
}
237
237
// cross-validation
238
- let profiles : RegionProfile [ ] = [ ]
239
- try {
240
- profiles = await this . listRegionProfile ( )
241
- } catch ( e ) {
242
- telemetry . amazonq_profileState . emit ( {
243
- source : 'reload' ,
244
- amazonQProfileRegion : 'not-set' ,
245
- reason : ( e as Error ) . message ,
246
- result : 'Failed' ,
247
- } )
248
-
249
- return
250
- }
238
+ this . listRegionProfile ( )
239
+ . then ( async ( profiles ) => {
240
+ const r = profiles . find ( ( it ) => it . arn === previousSelected . arn )
241
+ if ( ! r ) {
242
+ telemetry . amazonq_profileState . emit ( {
243
+ source : 'reload' ,
244
+ amazonQProfileRegion : 'not-set' ,
245
+ reason : 'profile could not be selected' ,
246
+ result : 'Failed' ,
247
+ } )
251
248
252
- const r = profiles . find ( ( it ) => it . arn === previousSelected )
253
- if ( ! r ) {
254
- telemetry . amazonq_profileState . emit ( {
255
- source : 'reload' ,
256
- amazonQProfileRegion : 'not-set' ,
257
- reason : 'profile could not be selected' ,
258
- result : 'Failed' ,
249
+ await this . invalidateProfile ( previousSelected . arn )
250
+ RegionProfileManager . logger . warn (
251
+ `invlaidating ${ previousSelected . name } profile, arn=${ previousSelected . arn } `
252
+ )
253
+ }
254
+ } )
255
+ . catch ( ( e ) => {
256
+ telemetry . amazonq_profileState . emit ( {
257
+ source : 'reload' ,
258
+ amazonQProfileRegion : 'not-set' ,
259
+ reason : ( e as Error ) . message ,
260
+ result : 'Failed' ,
261
+ } )
259
262
} )
260
- return
261
- }
262
263
263
- await this . switchRegionProfile ( r , 'reload' )
264
+ await this . switchRegionProfile ( previousSelected , 'reload' )
264
265
}
265
266
266
- private loadPersistedRegionProfle ( ) : { [ label : string ] : string } {
267
- const previousPersistedState = globals . globalState . tryGet < { [ label : string ] : string } > (
267
+ private loadPersistedRegionProfle ( ) : { [ label : string ] : RegionProfile } {
268
+ const previousPersistedState = globals . globalState . tryGet < { [ label : string ] : RegionProfile } > (
268
269
'aws.amazonq.regionProfiles' ,
269
270
Object ,
270
271
{ }
@@ -282,13 +283,13 @@ export class RegionProfileManager {
282
283
}
283
284
284
285
// persist connectionId to profileArn
285
- const previousPersistedState = globals . globalState . tryGet < { [ label : string ] : string } > (
286
+ const previousPersistedState = globals . globalState . tryGet < { [ label : string ] : RegionProfile } > (
286
287
'aws.amazonq.regionProfiles' ,
287
288
Object ,
288
289
{ }
289
290
)
290
291
291
- previousPersistedState [ conn . id ] = this . activeRegionProfile . arn
292
+ previousPersistedState [ conn . id ] = this . activeRegionProfile
292
293
await globals . globalState . update ( 'aws.amazonq.regionProfiles' , previousPersistedState )
293
294
}
294
295
@@ -337,7 +338,7 @@ export class RegionProfileManager {
337
338
338
339
const profiles = this . loadPersistedRegionProfle ( )
339
340
const updatedProfiles = Object . fromEntries (
340
- Object . entries ( profiles ) . filter ( ( [ connId , profileArn ] ) => profileArn !== arn )
341
+ Object . entries ( profiles ) . filter ( ( [ connId , profile ] ) => profile . arn !== arn )
341
342
)
342
343
await globals . globalState . update ( 'aws.amazonq.regionProfiles' , updatedProfiles )
343
344
}
0 commit comments