Skip to content

Browser Module

Manages the Camoufox browser lifecycle with crash detection and automatic recovery.

BrowserService

isReady(): boolean

Returns whether the browser is initialized and responsive.

getPage(): Promise<Result<Page, BrowserError>>

Creates a new browser page with the configured timeout. Returns a Playwright Page object.

Lifecycle

  • onModuleInit() — launches Camoufox via the camoufox-js library
  • onModuleDestroy() — graceful browser shutdown
  • Crash recovery — detects browser crashes and relaunches (max 3 retries)

What is Camoufox?

Camoufox is a stealth browser based on Firefox, designed to avoid bot detection. It patches browser fingerprinting vectors that headless Chrome/Playwright expose.

The project uses it for:

  • Reddit scraping (avoids rate limiting)
  • TikTok uploads (avoids CAPTCHA triggers)

Configuration

VariableDefaultDescription
BROWSER_HEADLESStrueRun headless (set false for login)
BROWSER_USER_DATA_DIR./data/browser-statePersistent session storage
BROWSER_TIMEOUT_MS30000Page operation timeout
BROWSER_HUMANIZE_DELAYStrueAdd random delays between actions

Error Codes

CodeDescription
LAUNCH_FAILEDCamoufox binary not found or failed to start
NOT_READYBrowser not initialized yet
PAGE_CREATION_FAILEDCould not create new page
BROWSER_CRASHEDBrowser process exited unexpectedly

Built with VitePress