JuliusBrussee/caveman · error
start browser
Error message
start browser: %w
What it means
NewCDPDriver allocates and starts a Chrome instance via chromedp; chromedp.Run(ctx) performs the initial browser launch and connection. If Chrome fails to launch (binary missing, flags rejected, crash) or the DevTools connection fails, the driver wraps the underlying error as 'start browser: %w' and cleans up the temp profile and contexts.
Solutions
- Read the wrapped cause (errors.Unwrap / %v) to see the real launch failure and fix it — usually 'exec: chromium: executable file not found' or a missing shared library
- Ensure a Chrome/Chromium binary is installed and either on PATH or explicitly configured (chromedp's executor options / executable path)
- In Docker, install chromium and its dependencies (or use a chrome-enabled base image) and pass --no-sandbox when running as root
- Ensure the temp profile directory is writable and the environment can open DevTools ports (not blocked by sandbox/seccomp policies)
Example fix
// before
driver, err := browse.NewCDPDriver(ctx) // fails in bare container
// after
// Dockerfile: apt-get install -y chromium && export CHROME_PATH=/usr/bin/chromium
// or ensure the driver locates the binary before retrying
if _, err := exec.LookPath("chromium"); err != nil {
return fmt.Errorf("chrome not installed: %w", err)
}
driver, err := browse.NewCDPDriver(ctx) Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := exec.LookPath("chromium"); err != nil {
return fmt.Errorf("chrome binary unavailable: %w", err)
} Try / catch
driver, err := browse.NewCDPDriver(ctx)
if err != nil {
var startErr error
if strings.HasPrefix(err.Error(), "start browser:") {
// inspect wrapped cause, ensure chrome installed/sandbox flags correct, retry once
startErr = err
}
return startErr
} Prevention
- Install Chrome/Chromium and required shared libraries in every deployment image
- Use --no-sandbox when running as root in containers
- Verify the browser launches in CI with the same flags you use in production
- Keep chromedp and Chrome versions reasonably current
When it happens
Trigger: Calling browse.NewCDPDriver when the Chrome/Chromium executable cannot be found or executed, the requested user-data-dir or flags are invalid, the binary crashes on startup, or the DevTools websocket endpoint cannot be reached within the allocation timeout.
Common situations: CI containers without Chrome installed; missing shared libraries (libnss3, libatk) in minimal Docker images; running as root without --no-sandbox; running headless=false on a headless server; stale or unwritable temp profile directory; version mismatch between chromedp and the installed Chrome.
Related errors
- element not actionable: last box=%+v
- unknown action
- browser function returned no result object
- browser function threw
- option not found
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/061a5a630393b13e.
Report an issue: GitHub.
Appendix: source
Thrown at browse/cdp.go:88
if !opts.Headless {
execOpts = append(execOpts, chromedp.Flag("headless", false))
}
allocCtx, allocCancel = chromedp.NewExecAllocator(parent, execOpts...)
}
var ctx context.Context
var cancel context.CancelFunc
if opts.TargetID != "" {
ctx, cancel = chromedp.NewContext(allocCtx, chromedp.WithTargetID(cdptarget.ID(opts.TargetID)))
} else {
ctx, cancel = chromedp.NewContext(allocCtx)
}
if err := chromedp.Run(ctx); err != nil {
cancel()
allocCancel()
if tmpProfile != "" {
_ = os.RemoveAll(tmpProfile)
}
return nil, fmt.Errorf("start browser: %w", err)
}
return &CDPDriver{allocCtx: allocCtx, allocCancel: allocCancel, ctx: ctx, cancel: cancel, tmpProfile: tmpProfile}, nil
}
func (d *CDPDriver) Close() error {
if d.cancel != nil {
d.cancel()
}
if d.allocCancel != nil {
d.allocCancel()
}
if d.tmpProfile != "" {
return os.RemoveAll(d.tmpProfile)
}
return nil
}
func (d *CDPDriver) TargetID() string {View on GitHub (pinned to 3ee70a1026)