Skip to main content
PuppeteerProvider drives a real headless Chromium browser through the Puppeteer library. Unlike FetchProvider, it executes JavaScript on every page it visits, which means single-page applications, lazy-loaded content, and client-side-rendered portfolios are all resolved correctly. A single browser process is launched on first use and reused across multiple getPageContent calls; each URL gets its own fresh page that is closed immediately after.

Installation

Puppeteer is listed as a direct dependency of @clyrisai/gitresolve and is downloaded automatically:
For a global CLI install the bundled Puppeteer may not be on the path. If BROWSER_PROVIDER=puppeteer gitresolve reports that the provider is unavailable, install Puppeteer globally alongside it:
Set BROWSER_PROVIDER=puppeteer in your shell profile to make Puppeteer the default for every run without touching your code.

Usage

Direct instantiation

Always call provider.cleanup() in a finally block so the browser process is terminated even if an error occurs:

Via the factory

CLI

To use PuppeteerProvider from the command line, set the BROWSER_PROVIDER environment variable:

How it works

1

Lazy browser launch

The first call to getPageContent triggers ensureBrowser(), which imports Puppeteer dynamically and launches Chromium with the flags --no-sandbox and --disable-setuid-sandbox. Subsequent calls reuse the same browser instance.
2

New page per URL

For every getPageContent call, a fresh browser page (browser.newPage()) is created. This prevents cookies, local storage, and cached state from leaking between requests.
3

Navigation and content extraction

Puppeteer navigates to the URL using page.goto(url, { waitUntil, timeout }) and then calls page.content() to retrieve the fully rendered HTML — including all content injected by JavaScript.
4

Page teardown

The page is closed in a finally block after each call, regardless of whether navigation succeeded or threw an error.
5

Browser cleanup

Calling provider.cleanup() closes the Chromium process and sets the internal reference to null. After cleanup, the next getPageContent call will re-launch the browser automatically.

Launch arguments

Chromium is always started with the following flags:

Options

waitUntil values

Always call provider.cleanup() in a finally block. If your process exits without calling it, the Chromium subprocess will be left running in the background. Over time this can exhaust system memory and file descriptors in long-lived services.