Skip to content

Session crash: Cannot read properties of null (reading 'awaitActivePage') during act() after CDP activity #349

Description

@vpendyal73

Description

Stagehand 3.20+ crashes with Cannot read properties of null (reading 'awaitActivePage') during act() calls after rapid CDP interactions. The crash occurs non-deterministically but frequently when running UI automation loops that perform many sequential Accept/Reject clicks.

Steps to Reproduce

  1. Start a Stagehand session
  2. Navigate to a complex single-page application (Salesforce Lightning in our case)
  3. Execute a loop that performs rapid act() calls (e.g., click Accept buttons in a list)
  4. After 5-15 minutes of continuous activity, the session crashes

Environment

  • Stagehand version: 3.21.0, 3.22.0 (crash), 3.19.5 (stable)
  • OS: macOS 15.5 (Darwin 25.5.0)
  • Python: 3.14.6
  • Browser: Chromium (Stagehand-bundled)

Error Log

12:38:21 INFO HTTP Request: POST http://127.0.0.1:52802/v1/sessions/.../act "HTTP/1.1 200 OK"
12:38:23 INFO HTTP Request: POST http://127.0.0.1:52802/v1/sessions/.../act "HTTP/1.1 500 Internal Server Error"

... Stagehand server log shows:
TypeError: Cannot read properties of null (reading 'awaitActivePage')
    at BrowserContext.<anonymous> (/.../stagehand-darwin-arm64:7:15833)

Workaround

Downgrade to Stagehand 3.19.5:

pip install stagehand==3.19.5

Version 3.19.5 is stable and can run the same workload for 30+ minutes without crashing.

Additional Context

The crash appears to be a CDP session race condition. After many rapid CDP interactions (act/observe cycles), the internal page reference becomes null. The awaitActivePage property access then fails.

This is blocking our UI test automation suite. Happy to provide more details or test patches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions