File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::collections::HashMap;
55use std:: net:: SocketAddr ;
66use std:: path:: PathBuf ;
77
8+ use anyhow:: Context as _;
89use axum:: error_handling:: HandleError ;
910use axum:: extract:: ws:: { self , WebSocket } ;
1011use axum:: extract:: { Path , WebSocketUpgrade } ;
@@ -99,12 +100,14 @@ pub async fn run_server(options: Options, output: WasmBindgenOutput) -> Result<(
99100 . fallback_service ( serve_dir)
100101 . layer ( middleware_stack) ;
101102
102- let mut address_string = options. address ;
103- if !address_string. contains ( ':' ) {
104- address_string +=
105- & ( ":" . to_owned ( ) + & pick_port:: pick_free_port ( 1334 , 10 ) . unwrap_or ( 1334 ) . to_string ( ) ) ;
106- }
107- let addr: SocketAddr = address_string. parse ( ) . expect ( "Couldn't parse address" ) ;
103+ let addr: SocketAddr = options
104+ . address
105+ . parse ( )
106+ . or_else ( |_| {
107+ format ! ( "{}:{}" , options. address, pick_port:: pick_free_port( 1334 , 10 ) . unwrap_or( 1334 ) )
108+ . parse ( )
109+ } )
110+ . context ( "Error parsing WASM_SERVER_RUNNER_ADDRESS" ) ?;
108111
109112 if options. https {
110113 let certificate = certificate:: certificate ( ) ?;
You can’t perform that action at this time.
0 commit comments