Infrastructure / Guide
How remote browser sessions work
Design allocation, readiness, attachment, reconnects, and cleanup as an explicit lifecycle.
A remote browser session moves through allocation, readiness, active use, and release. Making those transitions explicit helps automation recover from failures without creating duplicate work or leaving unused browsers running.
Model the lifecycle
Requested → Allocating → Ready → Attached → Working → Releasing → Released
↓ ↓ ↓
Failed Disconnected / ExpiredThis is a suggested application model, not a list of Remote Browser API status values. Adapt it to the actual API and timeout behavior of the service you use.
Allocation and readiness
Accepting a request is not the same as having a browser ready for CDP attachment. Record these timestamps separately. If your application retries allocation, determine whether the API supports idempotency or whether you need to reconcile the first allocation before requesting another.
Store a non-secret session identifier for operational correlation. Pass the credential-bearing connection URL through a secret channel to the worker that needs it. Avoid including that URL in metrics labels, traces, exception messages, or shared task output.
Attachment and ownership
Once attached, inspect existing contexts and tabs. Creating a new context can discard access to the authenticated state you intended to reuse. Conversely, attaching to a shared context can let two workers interfere with each other. Establish one navigation owner per task unless your workflow deliberately coordinates several clients.
A human viewer is useful for observing progress and renewing authentication. If the viewer permits control, pause the agent's input during takeover and explicitly return ownership afterward. See live preview and recording.
Failure recovery
A network disconnect does not reveal whether an action completed. Reconnect to the same allocation when supported, inspect the destination state, and resume from a verified checkpoint. When a browser has expired, restore only the supported saved state and revalidate authentication.
For side effects, a screenshot alone may be insufficient evidence. Prefer a stable confirmation identifier or the site's recorded result when available. Define what the task will do if the outcome cannot be determined safely.
Release and reconciliation
Release the allocation after success, cancellation, or failure through the service's documented mechanism. Add a periodic reconciliation process for sessions whose worker disappeared. Keep cleanup failures visible rather than counting them as successful completion.
Measure allocation time, attach time, active task time, and release time independently. This exposes both user-visible delay and paid idle time. Continue with the timing methodology, session definitions, and architecture.