Skip to content

fix: detect fetch-blocked ports up front instead of failing every check - #99

Merged
dacharyc merged 1 commit into
mainfrom
fix/blocked-port-preflight
Aug 9, 2026
Merged

fix: detect fetch-blocked ports up front instead of failing every check#99
dacharyc merged 1 commit into
mainfrom
fix/blocked-port-preflight

Conversation

@dacharyc

@dacharyc dacharyc commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Vendor the WHATWG fetch bad port list in a new src/helpers/blocked-ports.ts helper (undici implements the list but does not export it)
  • Fail fast in createContext when the target URL's port is on the list, with an error naming the port and suggesting safe alternatives, instead of thirteen opaque "fetch failed" check results
  • Catch runner errors in the check command and print them cleanly (previously a thrown runner error surfaced as an unhandled rejection)
  • Update the "Pick a safe port" section of docs/run-locally.md to reflect that the tool now diagnoses this directly

Closes #97

Test plan

  • Unit tests for isBlockedPort / getBlockedPort / blockedPortMessage and for createContext throwing on blocked ports
  • npm test (1304 tests), npm run lint, prettier clean
  • Manual: afdocs check http://localhost:1719 exits 1 with the actionable error; safe ports unaffected

Node's fetch (undici) implements the WHATWG bad port list and refuses
requests to those ports before they reach the network, so running afdocs
against a dev server on e.g. 1719 failed every check with a bare
"fetch failed". Vendor the list, fail fast in createContext with an
error naming the port and safe alternatives, and print runner errors
cleanly from the CLI instead of an unhandled rejection.

Closes #97
@dacharyc
dacharyc force-pushed the fix/blocked-port-preflight branch from e522db9 to 380acc9 Compare August 9, 2026 02:29
@dacharyc
dacharyc merged commit a4c4840 into main Aug 9, 2026
2 checks passed
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.

Detect fetch-blocked ports up front instead of failing every check with "fetch failed"

1 participant