@@ -1216,6 +1216,53 @@ describe("server-channels auto restart", () => {
12161216 ) . toBe ( true ) ;
12171217 } ) ;
12181218
1219+ it ( "discards a deferred thaw target removed from the current account list" , async ( ) => {
1220+ let accountIds = [ "removed" ] ;
1221+ let failStart = false ;
1222+ const startAccount = vi . fn (
1223+ async ( context : ChannelGatewayContext < TestAccount > ) =>
1224+ await new Promise < void > ( ( resolve ) => {
1225+ context . abortSignal . addEventListener ( "abort" , ( ) => resolve ( ) , { once : true } ) ;
1226+ } ) ,
1227+ ) ;
1228+ installTestRegistry (
1229+ createTestPlugin ( {
1230+ listAccountIds : ( ) => accountIds ,
1231+ isConfigured : async ( ) => {
1232+ if ( failStart ) {
1233+ throw new Error ( "start preflight failed" ) ;
1234+ }
1235+ return true ;
1236+ } ,
1237+ startAccount,
1238+ } ) ,
1239+ ) ;
1240+ const manager = createManager ( ) ;
1241+ await manager . startChannels ( ) ;
1242+ await vi . waitFor ( ( ) => expect ( startAccount ) . toHaveBeenCalledOnce ( ) ) ;
1243+
1244+ failStart = true ;
1245+ const failedTargets = await restartRunningChannelAccounts ( manager , {
1246+ shouldContinue : ( ) => true ,
1247+ onError : ( ) => { } ,
1248+ } ) ;
1249+ expect ( failedTargets ) . toEqual ( [ { channelId : "discord" , accountId : "removed" } ] ) ;
1250+
1251+ accountIds = [ ] ;
1252+ failStart = false ;
1253+ const errors : string [ ] = [ ] ;
1254+ const second = await restartRunningChannelAccounts (
1255+ manager ,
1256+ { shouldContinue : ( ) => true , onError : ( message ) => errors . push ( message ) } ,
1257+ { kind : "deferred-retry" , targets : failedTargets } ,
1258+ ) ;
1259+
1260+ expect ( second ) . toEqual ( [ ] ) ;
1261+ expect ( errors ) . toEqual ( [ ] ) ;
1262+ expect ( startAccount ) . toHaveBeenCalledOnce ( ) ;
1263+ expect ( manager . getRuntimeSnapshot ( ) . channelAccounts . discord ?. removed ) . toBeUndefined ( ) ;
1264+ } ) ;
1265+
12191266 it . each ( [ "disabled" , "unconfigured" ] as const ) (
12201267 "does not retain an account that becomes %s during host-thaw recovery" ,
12211268 async ( skipReason ) => {
0 commit comments