Skip to content

test: guard test ports against the fetch bad-ports list - #1462

Merged
vivek7405 merged 1 commit into
mainfrom
fix/guard-test-ports
Sep 2, 2026
Merged

test: guard test ports against the fetch bad-ports list#1462
vivek7405 merged 1 commit into
mainfrom
fix/guard-test-ports

Conversation

@vivek7405

Copy link
Copy Markdown
Collaborator

Follow-up to #1461, which re-based two dev-server test ports off 10080. That fixed those two files and nothing else: the next dev-server test starts from a copy of whichever neighbour is nearest, so the same range can come back.

Why guard the class

The cost of this bug is out of proportion to the typo behind it.

  • It is deterministic given the pid, not timing-dependent. A re-run almost always goes green, so it reads as flake for as long as it survives, and re-running is the first thing anyone tries.
  • The symptom points nowhere near the cause. dev-morph-verdict.mjs had the same exposure and fails as AssertionError: dev server never came up, while the server log captured in that same failure says webjs dev server ready on http://localhost:10080. The server is fine. The readiness poll simply cannot reach it, because fetch() refuses the port before opening a socket.

What it does

Reads the base + (process.pid % n) declarations out of the test sources, computes each reachable range, and fails if any range covers a port on the WHATWG Fetch bad-ports list.

It reads rather than imports, because these modules spawn a real dev server on import. Evaluating them here would cost minutes and, at the wrong pid, would be the very failure being guarded against.

The full list is included rather than just 10080, since a future test is free to base itself anywhere. 10080 is the highest entry, so any range above it is permanently safe, which is the rule #1461 moved the two files to satisfy.

The second assertion is the important one

It fails if the guard stops finding the declarations at all. Without it the first assertion passes vacuously the moment the idiom is respelled or moved to a helper, which is the same shape as the og-card fit pass that shipped with a condition that could never be false and silently guarded nothing for its whole life.

Verification

Both assertions were run against their counterfactuals:

change result
none (current main) both pass
revert dev-public-before-warm to 10000 + (pid % 256) range assertion fails, naming the file, the range and 10080
break the pattern so nothing is found vacuity assertion fails, reporting 0 found

Guard-only. No production code and no existing test is touched.

#1461 re-based two dev-server test ports off 10080, which fixed those two
files and nothing else. The next dev-server test starts from a copy of
whichever neighbour is nearest, so the same range can come back.

The bug is worth guarding as a CLASS rather than as two constants,
because its cost is out of proportion to the typo. It is deterministic
given the pid rather than timing-dependent, so a re-run goes green and it
reads as flake for as long as it survives. And the symptom points nowhere
near the cause: dev-morph-verdict fails as "dev server never came up"
while its own captured log says the server is ready on 10080. The server
is fine, the poll just cannot reach it.

This reads the port declarations out of the source and fails if any range
covers a WHATWG bad port. It reads rather than imports because these
modules spawn a real dev server on import, so evaluating them here would
cost minutes and, at the wrong pid, would be the very failure being
guarded against.

The second assertion is the one that matters most: it fails if the guard
stops finding the declarations at all. Without it the first passes
vacuously the moment the idiom is respelled, which is the same shape as
the og-card fit pass that shipped with a condition that could never be
false. Both assertions were verified against their counterfactuals: the
first fails when a port base is reverted, the second when the pattern is
broken.
@vivek7405
vivek7405 merged commit 4b8da0b into main Sep 2, 2026
10 checks passed
@vivek7405
vivek7405 deleted the fix/guard-test-ports branch September 2, 2026 20:03
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