Session lifecycle and cleanup
Session lifecycle and cleanup.
Creation is asynchronous
SDK creation normally reserves a session and polls until it is active. The default activation timeout is 600 seconds. A timeout can occur after a session ID has been allocated: inspect the exception and console before retrying, otherwise you may create duplicate billable sessions.
Automatic CAPTCHA processing
Automatic CAPTCHA processing is a per-session option and is disabled by default. In the console, select “Enable automatic CAPTCHA solving” when creating a Chromium session. With the SDK, use enableCaptcha: true in Node.js or enable_captcha=True in Python.
Both SDKs and the console send the same enable_captcha field to the session creation API. The service then detects and processes CAPTCHAs for that session automatically; other sessions in the project keep their own preferences. Availability and usage remain subject to the project plan and remaining CAPTCHA allowance.
See Node.js Capabilities and Python Capabilities for examples.
Always release both resources
The automation connection and the cloud session are separate resources. Disconnecting Puppeteer or closing the Playwright connection is not a substitute for closing the Lexmount session. Use nested try/finally blocks so a connection-close error cannot skip session cleanup; close the HTTP client last. The complete Playwright example shows this order.
Session close can begin asynchronous shutdown. If a Context is still locked, wait for final session closure and Context availability before reusing or deleting it. The Node SDK's session.close() logs some close failures rather than throwing them; for critical cleanup, verify the final session state through the console or session API. Do not treat a returned promise as proof of remote teardown.
Bound concurrency
Limit simultaneous sessions to your project's entitlement and available quota. A worker should acquire a slot, create a session, do bounded work, close it, and release the slot. Retry transient transport errors with bounded backoff; do not blindly retry create calls, authentication failures, or operations that submit a form/payment. A process kill can bypass finally: reconcile your own recorded session IDs before restarting jobs.
For Context-backed work, see persistent contexts. For retention and billing, see capabilities and pricing.
