test: guard test ports against the fetch bad-ports list - #1462
Merged
Conversation
#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.
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.
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.
dev-morph-verdict.mjshad the same exposure and fails asAssertionError: dev server never came up, while the server log captured in that same failure sayswebjs dev server ready on http://localhost:10080. The server is fine. The readiness poll simply cannot reach it, becausefetch()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:
main)dev-public-before-warmto10000 + (pid % 256)Guard-only. No production code and no existing test is touched.