@@ -546,7 +546,7 @@ async fn boot_simulator(
546546 State ( state) : State < AppState > ,
547547 Path ( udid) : Path < String > ,
548548) -> Result < Json < Value > , AppError > {
549- state . registry . remove ( & udid) ;
549+ forget_lifecycle_session ( & state , & udid) ;
550550 let action_udid = udid. clone ( ) ;
551551 run_bridge_action ( state. clone ( ) , move |bridge| {
552552 bridge. boot_simulator ( & action_udid)
@@ -559,25 +559,33 @@ async fn shutdown_simulator(
559559 State ( state) : State < AppState > ,
560560 Path ( udid) : Path < String > ,
561561) -> Result < Json < Value > , AppError > {
562+ forget_lifecycle_session ( & state, & udid) ;
562563 let action_udid = udid. clone ( ) ;
563564 run_bridge_action ( state. clone ( ) , move |bridge| {
564565 bridge. shutdown_simulator ( & action_udid)
565566 } )
566567 . await ?;
567- state. registry . remove ( & udid) ;
568568 simulator_payload ( state, udid) . await
569569}
570570
571571async fn erase_simulator (
572572 State ( state) : State < AppState > ,
573573 Path ( udid) : Path < String > ,
574574) -> Result < Json < Value > , AppError > {
575- state . registry . remove ( & udid) ;
575+ forget_lifecycle_session ( & state , & udid) ;
576576 let action_udid = udid. clone ( ) ;
577577 run_bridge_action ( state, move |bridge| bridge. erase_simulator ( & action_udid) ) . await ?;
578578 Ok ( json ( json_value ! ( { "ok" : true } ) ) )
579579}
580580
581+ fn forget_lifecycle_session ( state : & AppState , udid : & str ) {
582+ // SimulatorKit can reset the server-side connection if a cached private
583+ // display session is destructed while CoreSimulator is booting, shutting
584+ // down, or erasing the same device. Detach it from the registry without
585+ // running Objective-C teardown on the lifecycle response path.
586+ state. registry . forget ( udid) ;
587+ }
588+
581589async fn install_app (
582590 State ( state) : State < AppState > ,
583591 Path ( udid) : Path < String > ,
0 commit comments