Skip to content

fix(@angular/build): disable strictPort when port 0 is used in dev-server - #34055

Merged
alan-agius4 merged 3 commits into
angular:mainfrom
alan-agius4:fix-dev-server-flaky-tests
Sep 9, 2026
Merged

fix(@angular/build): disable strictPort when port 0 is used in dev-server#34055
alan-agius4 merged 3 commits into
angular:mainfrom
alan-agius4:fix-dev-server-flaky-tests

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

This PR addresses flaky test failures identified in the dev-server test suites:

@angular/build dev-server port collision:

  • When port: 0 is configured, an ephemeral port is requested. Previously strictPort: true was hardcoded in the Vite configuration, which caused dev-server restarts or rebuild error detection runs to fail if the ephemeral port was occupied before Vite bound to it.
  • Sets strictPort: port !== 0 (falling back to an open port when port: 0 is specified).

@angular-devkit/build-angular live-reload proxy test flakiness:

  • In serve-live-reload-proxies_spec.ts, the proxy HTTP server lacked an error handler, causing unhandled ECONNRESET errors when the headless browser disconnected or reloaded.
  • Replaced fixed 500ms timeouts with a waitForAppLiveReload polling helper that tolerates execution context destructions during live-reload navigation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces dynamic configuration for the strictPort option in the Angular dev-server, allowing it to be disabled when a random port (0) is requested. It also enhances test reliability in serve-live-reload-proxies_spec.ts by replacing hardcoded timeouts with a polling-based waitForAppLiveReload helper and ignoring proxy connection errors during reloads. The reviewer suggests a valuable improvement to use the resolved port variable instead of options.port when determining strictPort to avoid inconsistencies with environment overrides.

Comment thread packages/angular/build/src/builders/dev-server/options.ts Outdated
@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 9, 2026
…rver

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.
@alan-agius4
alan-agius4 requested a review from clydin September 9, 2026 10:17
… proxies dev-server test

Ignore proxy connection errors when the browser reloads or disconnects, and replace fixed setTimeout delays with waitForAppLiveReload polling helper to avoid navigation race conditions.
@alan-agius4
alan-agius4 force-pushed the fix-dev-server-flaky-tests branch from c61b090 to 843adb6 Compare September 9, 2026 10:18
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 9, 2026
@alan-agius4
alan-agius4 merged commit ebdf495 into angular:main Sep 9, 2026
39 of 40 checks passed
@alan-agius4
alan-agius4 deleted the fix-dev-server-flaky-tests branch September 9, 2026 14:21
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build area: @angular-devkit/build-angular target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants