BAP servers push event notifications to connected clients over the WebSocket connection. Events use JSON-RPC 2.0 notification format (no id, no response expected).
Subscribing to Events
Use events/subscribe to select which event types to receive:
Event Types
Console Events
Browser console messages (log, warn, error) forwarded to the client. Console errors are always forwarded; other levels require subscription.
Network Events
HTTP request and response events for 4xx/5xx responses. Sensitive headers are automatically redacted.
Headers containing credentials (authorization, cookie, set-cookie, x-api-key,
proxy-authorization, x-auth-token, x-csrf-token) are stripped from network events. Request
postData is always blanket-redacted.
Page Events
Page lifecycle events — navigation, load, close.
Dialog Events
Browser dialog events (alert, confirm, prompt, beforeunload).
Handle dialogs with dialog/handle:
Download Events
File download notifications.
Rate Limiting
The server enforces a rate limit of 100 events per second per page to prevent event floods (e.g., a page emitting thousands of console messages). Events exceeding the limit are dropped silently.
Rate limiter state is cleaned up when a page closes.
Event Handling in SDKs
CLI Event Streaming
The BAP CLI provides bap watch for live event monitoring in the terminal:
Events are color-coded by type: page events in blue, console in yellow/red, network in green/red, dialogs in magenta.