Skip to content

chore(e2e): RANGO_E2E_PORT_OFFSET — per-checkout port isolation for shared Playwright webServers - #711

Merged
ivogt merged 1 commit into
mainfrom
chore/e2e-port-offset
Jul 6, 2026
Merged

ivogt merged 1 commit into
mainfrom
chore/e2e-port-offset

Conversation

@ivogt

@ivogt ivogt commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

Two clones of this repo running e2e at the same time collide on the fixed fixture ports (rangojs-router 5188/5189 + host 5296/5297, cloudflare-basic 5198/5199). Under reuseExistingServer: !CI, the second run silently reuses the FIRST checkout's server — its tests execute against the other checkout's code with no error — and each run's stale-server cleanup kills the other's servers mid-flight (ERR_CONNECTION_REFUSED waves). This burned about an hour of phantom-failure chasing during #705 verification, when a parallel agent session in a sibling clone was running the same suites.

Change

One knob: RANGO_E2E_PORT_OFFSET (default 0 — zero behavior change). It shifts every fixture port uniformly in:

  • packages/rangojs-router/playwright.config.ts (dev/preview + host dev/preview)
  • packages/rangojs-router/e2e/host-routing.test.ts (builds absolute URLs from the same constants — reads the same env so it cannot drift from the config)
  • tests/cloudflare-basic/playwright.config.ts (dev/preview)

Uniform shifting preserves the deliberate cross-suite spacing (host 5296/5297 was chosen to avoid cloudflare-basic 5198/5199 — that invariant holds at any offset). All other suites (multi-router, vite-rsc-demo, no-typescript, stress-demo, …) already use dynamic per-test ports (findPort()) and need nothing.

Documented in AGENTS.md → Environment gotchas, so agent sessions learn to set it when a sibling clone may be testing.

Usage

# in clone B, while clone A is running e2e:
export RANGO_E2E_PORT_OFFSET=100
pnpm exec playwright test …   # all fixture servers bind 5288/5289/5396/5397/5298/5299

Test plan

Notes

  • CI is unaffected (single checkout per runner; env unset → offset 0).
  • Deliberate non-goal: auto-deriving an offset from the checkout path — implicit port drift is harder to debug than one explicit env var; the AGENTS.md note makes the knob discoverable exactly when the failure mode appears.

…he shared Playwright webServers

Two clones of this repo running e2e simultaneously collide on the fixed
fixture ports (rangojs-router 5188/5189 + host 5296/5297, cloudflare-basic
5198/5199): reuseExistingServer silently runs one checkout's tests against
the OTHER checkout's server (wrong code, no error), and each run's cleanup
kills the other's servers mid-flight. Bit hard during PR #705 verification.

RANGO_E2E_PORT_OFFSET (default 0 — no behavior change) shifts every fixture
port uniformly in both configs and in host-routing.test.ts (which builds
absolute URLs from the same constants), preserving the deliberate
cross-suite port spacing. Documented in AGENTS.md Environment gotchas.

Verified: offset 400 boots servers on 5588/5589/5696/5697 and 5599/5598;
content-negotiation (router dev, 23 passed) and cache-signal (cf-basic dev)
green against the shifted ports; default runs unchanged.
@pkg-pr-new

pkg-pr-new Bot commented Jul 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@rangojs/router@711

commit: 9fd4de3

@ivogt
ivogt merged commit 67f2099 into main Jul 6, 2026
34 checks passed
@ivogt
ivogt deleted the chore/e2e-port-offset branch July 6, 2026 19:05
ivogt added a commit that referenced this pull request Jul 6, 2026
… path, no setup required (#712)

Follow-up to #711: the env var only helps if a session already knows about
the multi-clone failure mode — the sessions that need isolation are exactly
the ones unaware of each other, so opt-in defends nothing by default.

checkoutPortOffset() in @shared/e2e hashes the checkout's absolute path
(resolved from the helper's own location through the workspace symlink) into
a 0..29800 offset (150 buckets x 200 stride). Every importer in the same
clone derives the identical value by construction: both playwright configs
and host-routing.test.ts (absolute URLs) import the one function, replacing
the keep-in-sync constants. Same clone, same ports across runs, so
reuseExistingServer still reuses your own servers; different clones get
disjoint blocks with zero setup. RANGO_E2E_PORT_OFFSET remains as explicit
override (0 forces the canonical bases); CI pins 0.

Verified: this clone derives 25800 — router e2e binds 30988/30989 (+host
31096/31097), cloudflare-basic binds 30999/30998 (same offset, cross-suite
spacing preserved); host-routing suite green against the derived ports
(config/test agreement); override 0/400 and CI=1 probed; all four local
sibling clones hash to distinct offsets (18200/25200/25600/25800).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant