Skip to content

docs: Runtime support section — Node vs Cloudflare Workers#9

Merged
jlc488 merged 1 commit into
mainfrom
docs/workers-runtime-limits
Jul 12, 2026
Merged

docs: Runtime support section — Node vs Cloudflare Workers#9
jlc488 merged 1 commit into
mainfrom
docs/workers-runtime-limits

Conversation

@jlc488

@jlc488 jlc488 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What

The README implied safeFetch works everywhere. It doesn't: it resolves targets with node:dns lookup, which Cloudflare Workers' nodejs_compat implements as a "Not implemented" throw (only the resolve* family works, via DoH) — and Workers fetch performs its own internal resolution, so userland can't pin a checked IP to the socket. Consumers deploying to Workers found out at runtime.

New section

Runtime support: Node vs Cloudflare Workers (both languages):

  • Support matrix: validateUrl / UrlPolicy / HostPolicy / guardToolInput* are pure and work everywhere; safeFetch + undici DNS pinning are Node-only.
  • Why the check-then-fetch gap is unclosable from inside a Worker.
  • Two recommended Workers patterns:
    1. Manual-redirect loop — fetch(redirect: 'manual') with per-hop validateUrl and a strict allowlist, including the derive-the-allowlist-from-the-submitted-URL variant for "crawl the customer's own site" flows.
    2. A Node-based guarded egress service calling safeFetch with pinDns: true for genuinely arbitrary URL fetching.

Also

README.ko.md was behind 0.3.0's English README — the redirect-hardening description and the DNS pinning subsection were never mirrored. Brought to parity.

Verification

Docs-only; test suite still green locally (124/124).

Context

First consumer of this guidance is AskLinq's URL ingestion (Workers runtime) — linq-kit roadmap Phase 1.5 flagged this exact doc gap.

safeFetch resolves targets with node:dns lookup, which Workers'
nodejs_compat implements as a 'Not implemented' throw (only the
resolve* family works, via DoH) — and Workers fetch does its own
internal resolution, so userland cannot pin a checked IP to the
socket. The README implied safeFetch was universal; consumers
deploying to Workers found out at runtime.

New section documents the support matrix (pure URL/policy/tool-input
checks work everywhere; safeFetch and undici pinning are Node-only),
explains why the gap is unclosable from inside a Worker, and shows
the two recommended Workers patterns: a manual-redirect loop with
per-hop validateUrl + strict allowlist (with the derive-the-allowlist-
from-the-submitted-URL variant for own-site crawling), and a Node
egress service with pinDns: true for genuinely arbitrary fetches.

Also brings README.ko.md up to parity with 0.3.0's English README —
the safeFetch redirect-hardening description and the DNS pinning
subsection had not been mirrored.

Tests: 124/124 green (docs-only change).
@jlc488
jlc488 merged commit eb81d44 into main Jul 12, 2026
1 check 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.

1 participant