fix(@angular/build): disable strictPort when port 0 is used in dev-server - #34055
Merged
Merged
Conversation
There was a problem hiding this comment.
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.
…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.
… 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
force-pushed
the
fix-dev-server-flaky-tests
branch
from
September 9, 2026 10:18
c61b090 to
843adb6
Compare
clydin
approved these changes
Sep 9, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses flaky test failures identified in the dev-server test suites:
@angular/builddev-server port collision:port: 0is configured, an ephemeral port is requested. PreviouslystrictPort: truewas 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.strictPort: port !== 0(falling back to an open port whenport: 0is specified).@angular-devkit/build-angularlive-reload proxy test flakiness:serve-live-reload-proxies_spec.ts, the proxy HTTP server lacked an error handler, causing unhandledECONNRESETerrors when the headless browser disconnected or reloaded.500mstimeouts with awaitForAppLiveReloadpolling helper that tolerates execution context destructions during live-reload navigation.