Environment:1broseidon Ketch Headless Browser
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Scrape, Browser_Rendering |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
Optional headless Chromium (via go-rod) used only when JS-shell detection escalates, installed on demand into the user cache directory; without it, shells fall back to cached HTML.
Description
This environment is the optional browser-rendering backend for ketch's scrape and crawl surfaces. It is not required to build or to get a first result — the fast HTTP path is the default, and the browser only launches when the JS-shell detector returns `likely_shell` (scrape) or a host's shell ratio crosses the crawl escalation threshold. The browser is go-rod driving a headless Chromium; `ketch browser install` downloads it via rod's `launcher` into `$XDG_CACHE_HOME/ketch/browser/` (or the platform equivalent).
The browser binary is resolved from the `browser` config key (`"chrome"`, `"chromium"`, or an absolute path); empty disables it. When enabled, ketch scrubs `KETCH_*` secret env vars from the child process (`config.ScrubbedEnviron`) so the browser never sees API keys, and strips the `HeadlessChrome/` UA token (relaunching once) to avoid bot-filter 403s.
Usage
Use this environment when scraping or crawling JavaScript-rendered sites: SPAs (Next.js, Nuxt, Vue, Svelte, Qwik, Astro islands), framework shells, or any page whose content streams in client-side. It is the prerequisite for the `--force-browser` scrape flag and for the crawl's adaptive browser escalation. Without it, those code paths degrade gracefully: shells are cached as `SourceHTTPShell` and a stderr warning is emitted, so ketch still answers.
A configured browser is not required for search, code search, docs, extract, or plain-HTTP scrape — those never touch it.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux / macOS / Windows | Chromium must run on the host; rod handles launch per-OS |
| Hardware | ~150-300 MB RAM per browser instance | Headless Chromium; CPU-bound render |
| Disk | ~250 MB | Chromium download in `$XDG_CACHE_HOME/ketch/browser/` |
Dependencies
System Packages
- A Chromium/Chrome binary, or network access to download one via `ketch browser install`
- No CGO — go-rod is pure Go and drives the browser over the DevTools Protocol
Go Modules
- `github.com/go-rod/rod` v0.116.2 (and its transitive deps: `fetchup`, `goob`, `got`, `gson`, `leakless`)
Credentials
No credentials for the browser itself. The scrape/crawl path may carry a Netscape `cookies.txt` (`cookie_file` config / `--cookie-file`), injected before navigation so consent-banner walls render real content. Cookies are never sent to the browser's environment; they are applied via CDP `SetCookies` on the page.
Quick Install
# Download Chromium into the ketch cache directory
ketch browser install
# Or point ketch at an existing Chrome/Chromium
ketch config set browser /usr/bin/chromium
# Verify
ketch browser status
Code Evidence
Browser launch with secret scrubbing and headless-token stripping from `scrape/browser.go:113-135`:
// Scrub KETCH_* secret vars (API keys, tokens) from the browser's
// environment — the child process has no use for ketch credentials.
l := launcher.New().Bin(binPath).Headless(true).Env(config.ScrubbedEnviron()...)
// ...
// Rod emulates devices.LaptopWithMDPIScreen by default, which overrides the
// user agent with a hardcoded macOS Chrome 114 string. ... Clear the
// emulation so pages see the real browser instead.
b := rod.New().ControlURL(u).DefaultDevice(devices.Clear)
Headless UA token (bot signal) from `scrape/browser.go:44-46`:
// headlessToken is the product-name prefix headless Chromium advertises in
// its User-Agent (e.g. "HeadlessChrome/151.0.0.0"). It is a strong bot
// signal: Akamai and similar filters answer a hard 403 to it, which made
// --force-browser unusable on exactly the sites it exists for (#45).
const headlessToken = "HeadlessChrome/"
Install path from `scrape/browser.go:242-249`:
cacheDir, err := os.UserCacheDir()
b := launcher.NewBrowser()
b.RootDir = filepath.Join(cacheDir, "ketch", "browser")
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `launch browser: ...` | No browser configured or not found | `ketch browser install`, or `ketch config set browser <path>` |
| `403 Forbidden` on `--force-browser` | HeadlessChrome UA token blocked by bot filter | Auto-handled by `stripHeadlessUA` relaunch; if it persists, set `user_agent` to a real browser UA |
| `download browser ... file exists` | Interrupted prior install left a partial tree | Remove `$XDG_CACHE_HOME/ketch/browser/<revision>/` and retry; install clears it first but a mid-extract crash can still leave cruft |
| `warn: JS-rendered; configure a browser for full content` | Shell detected, no browser configured | Run `ketch browser install`; the page was cached as `SourceHTTPShell` |
Compatibility Notes
- Optional, not mandatory: every surface works without a browser. Shells degrade to cached HTML with a warning; search/code/docs never need it.
- Bot-filter evasion: the `HeadlessChrome/` token is stripped by relaunching once with the modified UA (see `stripHeadlessUA`). Rod's default device emulation (a stale macOS Chrome 114 UA) is also cleared so pages see the real browser.
- Secret isolation: `config.ScrubbedEnviron()` removes every `KETCH_*` secret var from the browser's environment, so a dumped child-process env never leaks API keys.
- Cookies: injected via CDP `SetCookies` on an `about:blank` page before navigation, so consent-banner walls (which read the cookie on first paint) render real content. Cookies persist in the shared browser context within one process.
- Install is not atomic: an interrupted `ketch browser install` leaves a partial directory; the next attempt clears it first, but a crash mid-extract can still leave cruft that needs manual removal.