Documentation Index
Fetch the complete documentation index at: https://base.bangwu.me/llms.txt
Use this file to discover all available pages before exploring further.
Browser Automation Observability
When browser automation (Playwright, Stagehand, browser-use, etc.) fails, gets stuck, or can’t find an element, you need to see what actually happened — network requests, console errors, DOM changes, and screenshots aligned by timestamp. Thebrowser-trace skill makes this possible without disrupting your main automation.
Core Idea: Read-Only CDP Sidecar
Chrome DevTools Protocol (CDP) allows multiple clients to connect to the same browser target simultaneously. Your main automation sends commands through one CDP client. The trace skill connects a second, read-only CDP client that only subscribes to observation domains (Network, Console, Runtime, Log, Page) — never sending actions that change the page.CDP is designed for multiple clients. The main automation owns the “action” domains (DOM manipulation, input events). The trace client only subscribes to “observation” domains (Network events, Console messages, Page lifecycle). They coexist without interfering.
Three Mechanisms
1. Firehose — Raw CDP Event Stream
Captures all CDP events into NDJSON for post-hoc analysis:2. Sampler — Periodic Screenshots + DOM Snapshots
Periodically grabs screenshots and full-page HTML alongside the event stream:3. Bisector — Post-Run Segmentation
After the automation completes,bisect-cdp.mjs segments the raw event stream into structured, searchable chunks:
When to Use
- Automation fails / gets stuck — Find the exact moment it broke: which request failed, which JS error fired, which DOM element was missing
- Mid-session debugging — Attach trace to an already-running session without restarting
- Causal analysis — Align network, console, DOM, and screenshots by timestamp to trace root causes
Practical Constraints
- Sampling interval — Don’t sample faster than ~1s (default 2s). Each sample adds CDP/ screenshot overhead.
- DOM domain is noisy — Fine-grained DOM tree changes require adding
DOMtoO11Y_DOMAINS, but it generates very verbose output. - Always run stop-capture — Even if your code crashes, run
stop-capture.mjsto avoid zombie processes and missingstopped_attimestamps. - Bisect is idempotent — You can re-run it on the same data; it overwrites previous segmentations.
- Don’t re-open sessions — For remote automation with
browse --connect, don’t callbrowse env remoteto open a new session for the same browser target.
