@@ -516,6 +516,57 @@ describe("CloudManagedEndpointRuntime", () => {
516516 } ) ,
517517 ) ;
518518
519+ it . effect ( "remembers an HTTP/2 fallback the relay client made on its own" , ( ) =>
520+ Effect . gen ( function * ( ) {
521+ const context = yield * Layer . build (
522+ ServerSecretStore . layer . pipe (
523+ Layer . provide ( ServerConfig . layerTest ( process . cwd ( ) , { prefix : "t3-transport-test-" } ) ) ,
524+ Layer . provide ( Layer . mergeAll ( NodeServices . layer , NodeCrypto . layer ) ) ,
525+ ) ,
526+ ) ;
527+ const secretStoreLayer = Layer . succeed (
528+ ServerSecretStore . ServerSecretStore ,
529+ context . pipe ( Context . get ( ServerSecretStore . ServerSecretStore ) ) ,
530+ ) ;
531+ const start = ( spawner : ReturnType < typeof ChildProcessSpawner . make > ) =>
532+ buildCloudManagedEndpointRuntime (
533+ spawner ,
534+ layerRelayClientAvailable ,
535+ unusedHttpClient ,
536+ secretStoreLayer ,
537+ ) ;
538+ const registered = ( protocol : string ) =>
539+ `2026-11-10T01:43:17Z INF Registered tunnel connection connIndex=0 connection=c1 event=0 ip=198.41.192.7 location=fra08 protocol=${ protocol } \n` ;
540+
541+ yield * Effect . gen ( function * ( ) {
542+ const fixture = yield * makeTransportSpawner ( ) ;
543+ const runtime = yield * start ( fixture . spawner ) ;
544+ yield * runtime . applyConfig ( tunnelConfig ) ;
545+ yield * fixture . emit ( 0 , registered ( "quic" ) ) ;
546+ yield * Stream . runHead ( runtime . tunnelConnected ) ;
547+ } ) . pipe ( Effect . scoped ) ;
548+ yield * Effect . gen ( function * ( ) {
549+ const fixture = yield * makeTransportSpawner ( ) ;
550+ const runtime = yield * start ( fixture . spawner ) ;
551+ yield * runtime . applyConfig ( tunnelConfig ) ;
552+ expect ( fixture . spawned [ 0 ] ! . args ) . not . toContain ( "--protocol" ) ;
553+ // cloudflared, started with `auto`, gave up on QUIC itself.
554+ yield * fixture . emit ( 0 , registered ( "http2" ) ) ;
555+ yield * Stream . runHead ( runtime . tunnelConnected ) ;
556+ // The connector already runs on HTTP/2, so it is not restarted.
557+ expect ( fixture . spawned ) . toHaveLength ( 1 ) ;
558+ expect ( fixture . killed ) . toEqual ( [ ] ) ;
559+ } ) . pipe ( Effect . scoped ) ;
560+
561+ yield * Effect . gen ( function * ( ) {
562+ const fixture = yield * makeTransportSpawner ( ) ;
563+ const runtime = yield * start ( fixture . spawner ) ;
564+ yield * runtime . applyConfig ( tunnelConfig ) ;
565+ expect ( fixture . spawned [ 0 ] ! . args . slice ( - 3 ) ) . toEqual ( [ "--protocol" , "http2" , "run" ] ) ;
566+ } ) . pipe ( Effect . scoped ) ;
567+ } ) ,
568+ ) ;
569+
519570 it . effect (
520571 "ignores invalid or unreadable fallback state and still falls back if persistence fails" ,
521572 ( ) =>
0 commit comments