render

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 26 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package render is the headless Chrome step: it finds the user's installed Chrome or Chromium. refetch never downloads a browser.

Index

Constants

View Source
const (
	OutcomeSkippedOff    = "skipped_off"     // render = "off"
	OutcomeSkippedByCall = "skipped_by_call" // fetch_page(render: false)
	OutcomeNoChrome      = "no_chrome"       // no Chrome or Chromium found
	OutcomeSkippedRoot   = "skipped_root"    // running as root outside Linux, where Chrome's sandbox cannot run
)

Outcomes for a step 2 that was needed but did not run.

View Source
const Client = "headless"

Client is the attempt client name of the headless Chrome step.

View Source
const DefaultTimeout = 15 * time.Second

DefaultTimeout is render_timeout's default: Chrome start included.

Variables

View Source
var (
	ErrNoChrome = errors.New("no Chrome or Chromium found")
	ErrRoot     = errors.New("running as root: headless Chrome needs its sandbox, which does not run as root (on Linux, refetch runs it as nobody instead)")
	ErrTimeout  = errors.New("headless Chrome timed out")
	ErrSandbox  = errors.New("headless Chrome cannot start its sandbox here: the container blocks the user namespaces it needs (Docker's default seccomp profile does)")
)

Errors Render returns.

Functions

func FindChrome

func FindChrome() string

FindChrome returns the Chrome to run: REFETCH_CHROME if set, then the macOS app paths (also under ~/Applications), then PATH, then Playwright's Chromium. Empty means none.

func Name

func Name(ctx context.Context, chrome string) string

Name describes the installed Chrome for the stats header, like "Google Chrome 155"; "" when not found.

func UnsafePlaywrightChrome added in v0.2.0

func UnsafePlaywrightChrome() string

UnsafePlaywrightChrome is a Playwright Chromium that FindChrome passed over because others can write to it, as in Playwright's Docker images; "" when there is none.

func Version

func Version(ctx context.Context, chrome string) string

Version is the installed Chrome's version ("155.0.8059.85"), or "" if it cannot be read within three seconds. It is cached per binary.

Types

type Page added in v0.3.0

type Page struct {
	DOM []byte
	URL string
}

Page is what headless Chrome read: the DOM after the page's scripts ran (at most fetch.MaxBytes), and the address the page ended on.

type Renderer

type Renderer struct {
	Chrome  string        // binary; FindChrome() when empty
	Timeout time.Duration // hard cap, Chrome start included; DefaultTimeout when zero
	// contains filtered or unexported fields
}

Renderer runs the user's Chrome headless, behind a local proxy on the public-only dialer, and returns the DOM after the page's scripts ran.

func (*Renderer) Render

func (r *Renderer) Render(ctx context.Context, rawURL string) (Page, error)

Render loads rawURL in a throwaway headless Chrome profile and returns the DOM after the page's scripts ran, read over the DevTools pipe. It opens http and https URLs only: Chrome would open file: ones too.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL