FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(@angular/build): disable strictPort when port 0 is used in dev-se… · angular/angular-cli@a6e30fa · GitHub

Repository navigation

Commit a6e30fa

Browse files
committed
fix(@angular/build): disable strictPort when port 0 is used in dev-server
When port 0 is specified, an ephemeral port is selected. Previously, strictPort was hardcoded to true, which caused Vite to fail immediately if the ephemeral port was occupied during rebuilds or rapid restarts. strictPort is now set to false when port 0 is requested, allowing Vite to fall back to an available port. (cherry picked from commit 5d21812)
1 parent 2da5bc8 commit a6e30fa

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎packages/angular/build/src/builders/dev-server/options.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import { normalizeCacheOptions } from '../../utils/normalize-cache';
1313
import { ApplicationBuilderOptions } from '../application';
1414
import { Schema as DevServerOptions } from './schema';
1515

16-
export type NormalizedDevServerOptions = Awaited<ReturnType<typeof normalizeOptions>>;
16+
export type NormalizedDevServerOptions = Omit<
17+
Awaited<ReturnType<typeof normalizeOptions>>,
18+
'strictPort'
19+
> & {
20+
strictPort?: boolean;
21+
};
1722

1823
/**
1924
* Normalize the user provided options by creating full paths for all path based options
@@ -122,6 +127,7 @@ export async function normalizeOptions(
122127
buildTarget,
123128
host: host ?? 'localhost',
124129
port,
130+
strictPort: port !== 0,
125131
poll,
126132
open,
127133
verbose,

‎packages/angular/build/src/builders/dev-server/vite/server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async function createServerConfig(
5555
ssrFiles,
5656
},
5757
port: serverOptions.port,
58-
strictPort: true,
58+
strictPort: serverOptions.strictPort ?? true,
5959
host: serverOptions.host,
6060
open: serverOptions.open,
6161
allowedHosts: serverOptions.allowedHosts,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL