Skip to content

feat(preview): add Browser Run fallback for JS-rendered pages - #23

Merged
phatpham9 merged 7 commits into
mainfrom
feat/browser-preview-fallback
Nov 13, 2026
Merged

phatpham9 merged 7 commits into
mainfrom
feat/browser-preview-fallback

Conversation

@phatpham9

@phatpham9 phatpham9 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Adds a Browser Run fallback for HTML pages that still have no readable blocks after the static extractor and Workers AI conversion — typically JavaScript shells.
  • Keeps the fallback chain platform-side: Workers AI runs first, then Browser Run (env.BROWSER.quickAction("markdown", …)) only for no_content. PDFs/Office, too_large, blocked, timeout, and rate-limited failures never reach it.
  • Browser Run waits for networkidle2 with 8-second navigation/action and 9-second outer timeouts, blocks images/media/fonts and literal private-host requests, validates the rendered page status, redirect chain, and meta.finalUrl, and maps the Markdown through the existing validated block mapper.
  • Strips Browser Run's YAML frontmatter before mapping.
  • Adds the BROWSER binding and FEEDREADER_BROWSER_PREVIEW_FALLBACK (default true; false disables it).
  • Bumps the preview cache key to preview:v11 so previously cached empty previews get a render attempt.
  • Updates README/ARCHITECTURE/DEPLOYMENT/RUNBOOK with the Workers Free Browser Run limits (10 browser-minutes/day, one Quick Action per 10 seconds).

Security

  • Browser Run receives only the final URL already validated by core's stored-item allowlist and safe-redirect fetch.
  • The adapter re-validates the input URL, rejects literal private hosts/cloud-metadata names in every browser request, and rejects any rendered result whose redirect chain or final URL is not public.
  • Residual: Workers cannot pin DNS; a public hostname resolving to a private address is the same residual documented for the direct fetch path. Browser Run egress plus the stored-item allowlist bound it.

Verification

  • npm run typecheck
  • npx vitest run --exclude '.claude/**' — 16 files, 135 tests
  • npm run db:migrate:local
  • wrangler deploy --dry-run — 366.15 KiB / 97.08 KiB gzip; BROWSER binding present
  • Browser Run smoke test on a preview deployment: TodoMVC returned rendered Markdown, confirmed YAML frontmatter stripping and the private-request pattern; the second immediate call returned the expected 429 Rate limit exceeded, handled as no preview.
  • Full fallback-chain test on the preview deployment: a temporary JS-only fixture (empty static HTML, content injected 100 ms after load) returned a Browser preview test preview with the rendered heading + paragraph in 3.9 s. The fixture and temporary route were removed before this PR; they are not in the diff.
  • Normal article and PDF preview paths were re-checked separately and are unchanged.

Notes

  • Browser Run requests are identified as bots; sites that block automation still return no_content.
  • The fallback is best-effort: Browser Run errors/429s/timeouts return null and preserve the original failure reason.
  • PR fix(sources): fetch Hugging Face papers from the JSON API #22 (Hugging Face JSON API) is independent; this branch is based on main.

🤖 Generated with Claude Code

phatpham9 and others added 5 commits November 13, 2026 13:12
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Run HTML pages that still have no readable blocks after the static
extractor and Workers AI conversion through Browser Run's markdown
Quick Action. The chain keeps Workers AI first; Browser Run only runs
for no_content failures, checks the rendered page status and final URL,
and maps the returned Markdown through the same validated block mapper.

Browser Run's YAML frontmatter is stripped before mapping. Workers Free
limits (10 browser-minutes/day, one Quick Action per 10 seconds) are
documented and the fallback is behind
FEEDREADER_BROWSER_PREVIEW_FALLBACK. The preview cache key moves to v11.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🔎 Cloudflare preview: https://0e192035-feedreader.phatpham9.workers.dev

Uploaded from ff330dc3e729fa2bcb70f18f0b2f531d2af5d4ea. This is a Worker version preview — it shares the production D1 database, so it reads/writes real data; it does not receive cron-triggered refreshes.

phatpham9 and others added 2 commits November 13, 2026 13:22
Re-validate the fallback input URL at the adapter boundary and extend
the request-level reject pattern to cloud-metadata names and IPv6
private ranges. Validate every reported redirect hop and the rendered
final URL before returning any content.

The stored-item allowlist and core's safe-redirect fetch remain the
primary SSRF boundary; Browser Run egress covers DNS-resolved private
addresses, which Workers cannot pin. Add tests for invalid targets,
private redirects, and the reject pattern.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@phatpham9
phatpham9 merged commit ab6292b into main Nov 13, 2026
3 checks passed
@phatpham9
phatpham9 deleted the feat/browser-preview-fallback branch November 13, 2026 07:07
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