mirror of
https://github.com/microsoft/vscode.git
synced 2026-01-09 06:31:23 +08:00
Fix serve-web port randomization when --port 0 is specified (#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>
This commit is contained in:
parent
ae03121880
commit
90072b47cf
@ -127,7 +127,9 @@ pub async fn serve_web(ctx: CommandContext, mut args: ServeWebArgs) -> Result<i3
|
||||
};
|
||||
let builder = Server::try_bind(&addr).map_err(CodeError::CouldNotListenOnInterface)?;
|
||||
|
||||
let mut listening = format!("Web UI available at http://{addr}");
|
||||
// Get the actual bound address (important when port 0 is used for random port assignment)
|
||||
let bound_addr = builder.local_addr();
|
||||
let mut listening = format!("Web UI available at http://{bound_addr}");
|
||||
if let Some(base) = args.server_base_path {
|
||||
if !base.starts_with('/') {
|
||||
listening.push('/');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user