@@ -27,11 +27,16 @@ const encode = (value: string) => Stream.make(new TextEncoder().encode(value));
2727 * test set the outcome of the `off` (pre-clear) and `serve` calls separately —
2828 * they are the same subcommand and are told apart by the trailing `off`.
2929 */
30- const spawnerLayer = ( input : { readonly off ?: CallResult ; readonly serve ?: CallResult } ) =>
30+ const spawnerLayer = ( input : {
31+ readonly off ?: CallResult ;
32+ readonly serve ?: CallResult ;
33+ readonly calls ?: Array < ReadonlyArray < string > > ;
34+ } ) =>
3135 Layer . succeed (
3236 ChildProcessSpawner . ChildProcessSpawner ,
3337 ChildProcessSpawner . make ( ( command ) => {
3438 const args = "args" in command ? ( command . args as ReadonlyArray < string > ) : [ ] ;
39+ input . calls ?. push ( args ) ;
3540 const result : CallResult = args . includes ( "status" )
3641 ? { exitCode : 0 }
3742 : args . includes ( "off" )
@@ -102,6 +107,20 @@ describe("shareDevServer", () => {
102107 } ) ,
103108 ) ;
104109
110+ // Vite binds `localhost`, which modern Node resolves to `::1` first, so a
111+ // 127.0.0.1 target would proxy to a loopback nothing listens on.
112+ it . effect ( "proxies to the localhost name Vite binds, not 127.0.0.1" , ( ) =>
113+ Effect . gen ( function * ( ) {
114+ const calls : Array < ReadonlyArray < string > > = [ ] ;
115+ yield * shareDevServer ( { webPort : 5788 } ) . pipe (
116+ Effect . provide ( spawnerLayer ( { off : { exitCode : 0 } , calls } ) ) ,
117+ ) ;
118+
119+ const serveCall = calls . find ( ( args ) => args . includes ( "--bg" ) ) ;
120+ assert . deepEqual ( serveCall , [ "serve" , "--bg" , "--https=5788" , "http://localhost:5788" ] ) ;
121+ } ) ,
122+ ) ;
123+
105124 // The stale-mapping clear runs before serve, so a failure here leaves the
106125 // port serving nothing. Saying only "serve failed" would let an operator
107126 // assume their previous mapping survived.
0 commit comments