@@ -1020,6 +1020,11 @@ describe("EnvironmentRegistry", () => {
10201020 expect (
10211021 ( yield * SubscriptionRef . get ( registry . entries ) ) . get ( RELAY_TARGET . environmentId ) ?. enabled ,
10221022 ) . toBe ( false ) ;
1023+ expect ( yield * registry . state ( RELAY_TARGET . environmentId ) ) . toMatchObject ( { desired : false } ) ;
1024+ expect ( yield * Ref . get ( harness . storedDisabled ) ) . toEqual (
1025+ new Set ( [ RELAY_TARGET . environmentId ] ) ,
1026+ ) ;
1027+ expect ( yield * Ref . get ( harness . sessions ) ) . toHaveLength ( 0 ) ;
10231028 yield * registry . setEnabled ( RELAY_TARGET . environmentId , true ) ;
10241029 yield * awaitConnectionState (
10251030 registry ,
@@ -1030,13 +1035,16 @@ describe("EnvironmentRegistry", () => {
10301035 } ) ,
10311036 ) ;
10321037
1033- it . effect ( "a socket preflight rejection pauses the connection without switching it off " , ( ) =>
1038+ it . effect ( "protocol rejection preserves enablement through recovery and relaunch " , ( ) =>
10341039 Effect . gen ( function * ( ) {
10351040 const error = new ConnectionBlockedError ( {
10361041 reason : "unsupported" ,
10371042 detail : "Use a compatible client." ,
10381043 } ) ;
1039- const harness = yield * makeHarness ( [ RELAY_TARGET ] , [ ] , [ ] , { prepareError : error } ) ;
1044+ const rejection = yield * Ref . make < ConnectionBlockedError | undefined > ( error ) ;
1045+ const harness = yield * makeHarness ( [ RELAY_TARGET ] , [ ] , [ ] , {
1046+ beforePrepareRoute : ( ) => Ref . get ( rejection ) ,
1047+ } ) ;
10401048 yield * Effect . gen ( function * ( ) {
10411049 const registry = yield * EnvironmentRegistry . EnvironmentRegistry ;
10421050 yield * registry . start ;
@@ -1047,9 +1055,7 @@ describe("EnvironmentRegistry", () => {
10471055 Stream . take ( 1 ) ,
10481056 Stream . runDrain ,
10491057 ) ;
1050- expect ( ( yield * Ref . get ( harness . storedDisabled ) ) . has ( RELAY_TARGET . environmentId ) ) . toBe (
1051- false ,
1052- ) ;
1058+ expect ( yield * Ref . get ( harness . storedDisabled ) ) . toEqual ( new Set ( ) ) ;
10531059 expect (
10541060 ( yield * SubscriptionRef . get ( registry . entries ) ) . get ( RELAY_TARGET . environmentId ) ,
10551061 ) . toMatchObject ( { enabled : true , unsupportedReason : error . message } ) ;
@@ -1059,60 +1065,22 @@ describe("EnvironmentRegistry", () => {
10591065 ( state ) => ! state . desired && state . phase === "available" ,
10601066 ) ;
10611067 expect ( yield * Ref . get ( harness . sessions ) ) . toHaveLength ( 0 ) ;
1062- } ) . pipe ( Effect . provide ( harness . layer ) ) ;
1063- } ) ,
1064- ) ;
10651068
1066- it . effect ( "an enabled environment reconnects once its compatibility block clears" , ( ) =>
1067- Effect . gen ( function * ( ) {
1068- const harness = yield * makeHarness ( [ RELAY_TARGET ] ) ;
1069- const error = new ConnectionBlockedError ( {
1070- reason : "unsupported" ,
1071- detail : "Use a compatible client." ,
1072- } ) ;
1073- yield * Effect . gen ( function * ( ) {
1074- const registry = yield * EnvironmentRegistry . EnvironmentRegistry ;
1075- yield * registry . start ;
1069+ yield * Ref . set ( rejection , undefined ) ;
1070+ yield * registry . setCompatibility ( RELAY_TARGET . environmentId , null ) ;
10761071 yield * awaitConnectionState (
10771072 registry ,
10781073 RELAY_TARGET . environmentId ,
10791074 ( state ) => state . phase === "connected" ,
10801075 ) ;
1081-
1076+ expect ( yield * Ref . get ( harness . sessions ) ) . toHaveLength ( 1 ) ;
10821077 yield * registry . setCompatibility ( RELAY_TARGET . environmentId , error ) ;
10831078 yield * awaitConnectionState (
10841079 registry ,
10851080 RELAY_TARGET . environmentId ,
1086- ( state ) => state . phase === "available" ,
1087- ) ;
1088- expect (
1089- ( yield * SubscriptionRef . get ( registry . entries ) ) . get ( RELAY_TARGET . environmentId ) ,
1090- ) . toMatchObject ( { enabled : true , unsupportedReason : error . message } ) ;
1091- expect ( ( yield * Ref . get ( harness . storedDisabled ) ) . has ( RELAY_TARGET . environmentId ) ) . toBe (
1092- false ,
1093- ) ;
1094-
1095- yield * registry . setCompatibility ( RELAY_TARGET . environmentId , null ) ;
1096- yield * awaitConnectionState (
1097- registry ,
1098- RELAY_TARGET . environmentId ,
1099- ( state ) => state . phase === "connected" ,
1100- ) ;
1101- expect ( yield * Ref . get ( harness . sessions ) ) . toHaveLength ( 2 ) ;
1102- } ) . pipe ( Effect . provide ( harness . layer ) ) ;
1103- } ) ,
1104- ) ;
1105-
1106- it . effect ( "a blocked environment comes back enabled after a relaunch" , ( ) =>
1107- Effect . gen ( function * ( ) {
1108- const harness = yield * makeHarness ( [ RELAY_TARGET ] ) ;
1109- yield * Effect . gen ( function * ( ) {
1110- const registry = yield * EnvironmentRegistry . EnvironmentRegistry ;
1111- yield * registry . start ;
1112- yield * registry . setCompatibility (
1113- RELAY_TARGET . environmentId ,
1114- new ConnectionBlockedError ( { reason : "unsupported" , detail : "Use a compatible client." } ) ,
1081+ ( state ) => ! state . desired && state . phase === "available" ,
11151082 ) ;
1083+ expect ( yield * Ref . get ( harness . releasedSessions ) ) . toBe ( 1 ) ;
11161084 } ) . pipe ( Effect . provide ( harness . layer ) , Effect . scoped ) ;
11171085
11181086 yield * Effect . gen ( function * ( ) {
@@ -1795,6 +1763,15 @@ describe("EnvironmentRegistry", () => {
17951763 expect (
17961764 ( yield * SubscriptionRef . get ( registry . entries ) ) . get ( TARGET . environmentId ) ,
17971765 ) . toMatchObject ( { enabled : true , unsupportedReason : error . message } ) ;
1766+ yield * registry . registerPlatform (
1767+ new PrimaryConnectionRegistration ( {
1768+ target : new PrimaryConnectionTarget ( { ...TARGET , label : "Renamed" } ) ,
1769+ } ) ,
1770+ ) ;
1771+ expect ( yield * registry . state ( TARGET . environmentId ) ) . toMatchObject ( {
1772+ desired : false ,
1773+ phase : "available" ,
1774+ } ) ;
17981775 expect ( yield * Ref . get ( harness . sessions ) ) . toHaveLength ( 1 ) ;
17991776 yield * registry . registerPlatform (
18001777 new PrimaryConnectionRegistration ( {
0 commit comments