Skip to content

Commit 90072b4

Browse files
Copilotconnor4312
andauthored
Fix serve-web port randomization when --port 0 is specified (microsoft#254676)
* Initial plan * Fix serve-web port randomization when --port 0 is specified Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com> * Fix serve-web to display actual bound port instead of 0 When --port 0 is specified, the OS assigns a random port but the logging was showing port 0 instead of the actual assigned port. Fixed by reading the local_addr() from the server builder after binding. Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com>
1 parent ae03121 commit 90072b4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cli/src/commands/serve_web.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ pub async fn serve_web(ctx: CommandContext, mut args: ServeWebArgs) -> Result<i3
127127
};
128128
let builder = Server::try_bind(&addr).map_err(CodeError::CouldNotListenOnInterface)?;
129129

130-
let mut listening = format!("Web UI available at http://{addr}");
130+
// Get the actual bound address (important when port 0 is used for random port assignment)
131+
let bound_addr = builder.local_addr();
132+
let mut listening = format!("Web UI available at http://{bound_addr}");
131133
if let Some(base) = args.server_base_path {
132134
if !base.starts_with('/') {
133135
listening.push('/');

0 commit comments

Comments
 (0)