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.
|
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