Repository navigation
Env: Auto-fall-back to free port when defaults 8888/8889 busy - #78173
Draft
cbravobernal wants to merge 6 commits into
Draft
cbravobernal wants to merge 6 commits into
cbravobernal wants to merge 6 commits into
Conversation
|
Size Change: 0 B Total Size: 7.93 MB ℹ️ View Unchanged
|
Phase 0 of Radical Pipelines. Sets up project conventions (.claude/rp.md) and writes the phase-0 prompt artifact for issue #49843. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds spec.md (round-2 revision) plus spec-review-1.md (REJECTED, 2 blockers + 6 minors) and spec-review-2.md (APPROVED) produced by the spec-writer / spec-reviewer team for the autonomous Radical Pipelines run. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds plan.md (round-2 revision) plus plan-review-1.md (REJECTED, 3 blockers + 8 minors) and plan-review-2.md (APPROVED) produced by the plan-writer / plan-reviewer team. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When `wp-env start` runs with no explicit port configuration, the default ports 8888 (development) and 8889 (tests) now scan upward to the next free port if they are busy, instead of failing the start. User-set ports keep today's strict behavior — Docker reports a port conflict and the start fails — so an explicit `port: 9000` in `.wp-env.json` is never silently moved. `autoPort` becomes tri-state: unset (default) -> defaults-only fallback; `true` -> all ports fall back, matching the prior opt-in `--auto-port` flag from #74472; `false` -> hard opt-out, even default ports stay strict. The existing `process.env.CI` guard keeps CI runs deterministic regardless of the setting. Closes part of #49843. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Updates packages/env/README.md (autoPort tri-state row, rewritten
"Automatic Port Selection" section, --auto-port options block) and
packages/env/CHANGELOG.md ("Unreleased" → "New Features" bullet
referencing #49843 and #74472). Refines the --auto-port describe
string in lib/cli.js so wp-env start --help no longer claims that the
flag is required for default-port fallback.
Includes RP phase 5 review artifacts (docs-review-1 REJECTED, 1
blocker; docs-review-2 APPROVED) produced by the doc-writer /
doc-reviewer team.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Removes .claude/rp.md and .pipelines/49843-wp-env-default-port-fallback/. The pipeline conventions and per-phase review artifacts were useful during authoring but should not land on trunk. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cbravobernal
force-pushed
the
try/49843-wp-env-default-port-fallback
branch
from
May 12, 2026 09:39
82ad9de to
00ef5a1
Compare
This branch has not been deployed
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.
What?
Closes part of #49843.
wp-env startnow auto-falls-back to the next free port when the default8888(development) or8889(tests) is busy on the host, without requiring--auto-port. Explicit user-set ports keep today's strict behavior.Why?
wp-env's "out of the box" promise depends on8888/8889being free. On any machine that already runs another local stack on8888, contributors have to either free the port or write a.wp-env.jsonbefore they canwp-env start. PR #74472 added--auto-portas an opt-in, which helps experienced contributors but does not improve the first-run experience. This PR closes that gap by making the fallback automatic for the default ports while preserving the strict behavior for ports the contributor explicitly chose.How?
autoPortbecomes a tri-state (boolean | null):null(default, unset)8888/8889auto-fall-back; user-set ports stay stricttrue(or--auto-port)falseImplementation:
parseConfignow attaches a non-enumerable__defaultOriginPorts: Set<string>to the merged config so existing destructurings andtoEqual(DEFAULT_CONFIG)snapshots stay byte-identical.loadConfigresolves a tri-stateautoPortMode('all' | 'defaults-only' | 'off') and threads it plus the default-origin set intopostProcessConfig.resolveConfigPortsroutes per-port to either the strict (isPortAvailable) or non-strict (findAvailablePort) branch based on whether the port is in the default-origin set under the chosen mode.createPortResolveremits a one-linespinner.info(...)when the resolved port differs from the preferred one, then re-arms the spinner.process.env.CIguard is preserved as the always-strict override for CI determinism.No new top-level config options. No changes outside
packages/env/.Test plan
Automated:
npm run test:unit -- packages/env—181 passed, 181 total(was 138; +43 new tests cover the new behavior, including AC8 regression detector for theCIguard).npm run lint:js -- packages/env— clean.composer test— to be run by reviewer with wp-env started locally (was skipped during implementation because wp-env was not running on this branch). Spec R-PHPRegress requires this gate before merge.Manual reproduction (covers spec AC9b):
npx http-server -p 8888 &— block the default development port.cdinto a project with no.wp-env.jsonand runnpm exec -- wp-env start. Expect: aspinner.infoline saying the development port moved to8890(or the next free one) and the environment to come up at the new port..wp-env.jsonto set"port": 9000. Block9000withnpx http-server -p 9000 &. Runnpm exec -- wp-env startagain. Expect: the existing port-busy / Docker bind error — the explicit9000is NOT silently moved."autoPort": trueto.wp-env.json(keepport: 9000, keep9000blocked). Runwp-env start. Expect: fallback to the next free port and aspinner.infonotice (matches PR wp-env: Add opt-in --auto-port flag for automatic port selection #74472 opt-in semantics)."autoPort": falsein.wp-env.json(noportoverride, with8888blocked). Runwp-env start. Expect: port-busy / Docker bind error — even default ports do NOT auto-fall-back."autoPort"removed and8888blocked, runCI=1 wp-env start. Expect: port-busy / Docker bind error — CI guard forces strict on defaults.Notes for reviewers
.pipelines/49843-wp-env-default-port-fallback/and can be deleted before squash-merge if they should not land ontrunk.tools/eslint/config.mjsimportseslint-plugin-react-hooks@7.1.1. If your local install is older you may neednpm installbefore lint passes.--auto-portdescribe string inlib/cli.jswas updated sowp-env start --helpnow reflects the tri-state.🤖 Generated with Claude Code