Repository navigation
fix: assign distinct ports to dev servers sharing devServer options - #4886
Conversation
Ports from the OS can be taken by other connections before the dev server listens, the helper takes them from a range of the Jest worker. Claude-Session: https://claude.ai/code/session_013FhutRFjuQemBzekJMYcqL
Configurations can share one devServer object, the port assigned to the first dev server was written to it and reused by the others. Enable the test for multiple dev servers without ports. Claude-Session: https://claude.ai/code/session_013FhutRFjuQemBzekJMYcqL
🦋 Changeset detectedLatest commit: c0cf560 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (d4ee8bd). Install it locally:
npm i -D create-webpack-app@https://pkg.pr.new/create-webpack-app@d4ee8bd webpack-cli@https://pkg.pr.new/webpack-cli@d4ee8bd
yarn add -D create-webpack-app@https://pkg.pr.new/create-webpack-app@d4ee8bd webpack-cli@https://pkg.pr.new/webpack-cli@d4ee8bd
pnpm add -D create-webpack-app@https://pkg.pr.new/create-webpack-app@d4ee8bd webpack-cli@https://pkg.pr.new/webpack-cli@d4ee8bd |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4886 +/- ##
=======================================
Coverage 95.07% 95.08%
=======================================
Files 14 14
Lines 5873 5874 +1
Branches 895 894 -1
=======================================
+ Hits 5584 5585 +1
Misses 288 288
Partials 1 1
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
No actionable comments were generated in the recent review.
|
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [webpack-cli](https://github.com/webpack/webpack-cli/tree/main/packages/webpack-cli) ([source](https://github.com/webpack/webpack-cli)) | [`7.2.3` → `7.3.1`](https://renovatebot.com/diffs/npm/webpack-cli/7.2.3/7.3.1) |  |  | --- ### Release Notes <details> <summary>webpack/webpack-cli (webpack-cli)</summary> ### [`v7.3.1`](https://github.com/webpack/webpack-cli/blob/HEAD/CHANGELOG.md#731) [Compare Source](https://github.com/webpack/webpack-cli/compare/webpack-cli@7.3.0...webpack-cli@7.3.1) ##### Patch Changes - fix: detect missing package managers and failed installations, without a lock file the CLI chose npm even when it wasn't installed instead of yarn or pnpm, and it continued after a package failed to install (by [@​alexander-akait](https://github.com/alexander-akait) in [#​4889](webpack/webpack-cli#4889)) - chore: replace the `import-local` and `cross-spawn` dependencies with Node.js built-ins (by [@​alexander-akait](https://github.com/alexander-akait) in [#​4889](webpack/webpack-cli#4889)) - chore: load configuration files with `import()` instead of `eval` (by [@​alexander-akait](https://github.com/alexander-akait) in [#​4893](webpack/webpack-cli#4893)) ### [`v7.3.0`](https://github.com/webpack/webpack-cli/blob/HEAD/CHANGELOG.md#730) [Compare Source](https://github.com/webpack/webpack-cli/compare/webpack-cli@7.2.3...webpack-cli@7.3.0) ##### Minor Changes - feat: run `webpack-dev-server@6` as a compiler plugin. The CLI drives watch compilation, prints build stats and closes the compiler on shutdown. Older dev servers continue to manage their own compilation. (by [@​bjohansebas](https://github.com/bjohansebas) in [#​4847](webpack/webpack-cli#4847)) In multi-compiler mode, every dev server serves all compilers by default. Use the new `--dev-server-per-compiler` option of `webpack serve` to serve each compiler only by the dev server from its own configuration. - feat: add shell completions for zsh, bash, fish and powershell through the `complete` command (by [@​alexander-akait](https://github.com/alexander-akait) in [#​4840](webpack/webpack-cli#4840)) ##### Patch Changes - fix: keep multi-compiler options such as `parallelism` and `plugins` set on a configuration array when `--config-name` or `extends` rebuild it (by [@​alexander-akait](https://github.com/alexander-akait) in [#​4871](webpack/webpack-cli#4871)) - perf: share the compile cache with child processes and worker threads, such as minimizer workers, so they start warm too (by [@​alexander-akait](https://github.com/alexander-akait) in [#​4872](webpack/webpack-cli#4872)) - fix: assign distinct ports to dev servers of configurations that share the same `devServer` object. (by [@​alexander-akait](https://github.com/alexander-akait) in [#​4886](webpack/webpack-cli#4886)) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - "before 9am on tuesday" - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODguMiIsInVwZGF0ZWRJblZlciI6IjQ0LjE4OC4yIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==--> Reviewed-on: https://code.futo.org/harbor/harbor/pulls/2163
Follow-up to #4847 and #4885. Fixes #2408 for webpack-dev-server 6.
Shared
devServeroptionsMulti-configurations often share one
devServerobject between configurations. The automatic port of the first dev server was written to that shared object, so every other dev server got the same port and failed withEADDRINUSE. The CLI now copies the options for each configuration.Test for multiple dev servers without ports
The test for #2408 ("should work in multi compiler mode with multiple dev servers") was skipped. It now runs with webpack-dev-server 6:
devServerobject;Its config imported the shared options with
const { devServerConfig } = require(...), but the helper exports the object itself, sodevServerwasundefined. Other configs import it the same way; they are left unchanged to keep their snapshots.The test fails without the fix and passes with it.
Free ports in the new serve tests
The serve tests added in #4847 (
automatic-ports,error-handling,per-compiler,rebuild) now usegetFreePortfrom #4885. Before, they took ports from the ephemeral range, where other connections can take them before the dev server listens.getFreePortaccepts ports to exclude, as the per-compiler test needs two.Generated by Claude Code
Summary by CodeRabbit