Skip to content

fix(extension): avoid work for suppressed CDP logs - #3326

Open
raederhans wants to merge 1 commit into
browserbase:mainfrom
raederhans:fix/suppressed-cdp-logging-overhead
Open

raederhans wants to merge 1 commit into
browserbase:mainfrom
raederhans:fix/suppressed-cdp-logging-overhead

Conversation

@raederhans

Copy link
Copy Markdown

why

Addresses the logging-overhead portion of #3239. This does not close the whole issue: Runtime/DOM setup caching and element-handle reuse are intentionally out of scope.

Suppressed records currently reach schema validation, payload serialization and log-span creation. CDP calls and unsolicited events also serialize their debug payloads before the logger can filter them.

what changed

  • Add an inexpensive StagehandLogger.isEnabled() check and filter suppressed records before validation/serialization/span creation. Keep the final emission check so a data getter or span processor changing the level to off still prevents emission.
  • Guard expensive CDP debug payload construction for root calls, session calls and events. Custom { debug, error } loggers without a level query retain concrete-object payloads and their previous behavior.
  • Keep required wire serialization, enabled log data/context, response errors, and normal operation/request spans. Serialize the wire payload before registering inflight work so cyclic, BigInt or throwing-toJSON inputs do not introduce retained pending requests.
  • Add deterministic regression tests, update tests that previously expected filtered log spans, and include extension/TypeScript/Python patch changesets.

test plan

Passed locally on Node 24.22.1:

  • Focused logger/CDP/RPC tests: 43 passed. The first regression run against unmodified production code had 9 failures / 16 passes; the original focused suite passed before adding regressions.
  • Complete extension unit suite: 1,074 passed, 9 todo across 68 files. Before publication, the patch applied cleanly to latest main (59346d0); the extension suite again passed 1,074 tests, with extension build/typecheck and release-metadata checks passing. The compatibility run used two test workers after a parallel artifact-comparison timeout.
  • Independent adversarial harness: 28/28 passed, including dynamic levels, throwing getters, cyclic/BigInt/throwing-toJSON payloads, legacy custom loggers, scoped context, error rejection and operation-span preservation.
  • Extension build/typecheck, just fmt, targeted formatting/lint, release metadata checks, Python generated-code drift/lock/ruff/type checks, and git diff --check.
  • Workspace formatting/lint/typecheck excluding the docs validator: 42/42 tasks passed, using concurrency 2.
  • Python suite: 1,052 passed, 5 skipped. The sandbox's SOCKS proxy required installing socksio into the local test environment only; no dependency manifests were changed.
  • SDK package-install contract passed with writable cache directories.

A deterministic 100-call mixed root/session harness measured parameter serialization 200 → 100, log spans 200 → 0, wire messages 100 → 100, and operation spans 1 → 1. These are work counts, not browser timing or end-to-end performance claims.

The full repository gates are not green in this sandbox. The docs validator cannot enumerate network interfaces; a root release test requires a blocked local tsx IPC socket; an eval-doctor test detects the sandbox's read-only Codex home; browser suites cannot launch Chromium (socket() EPERM) and a cross-version test cannot resolve the package registry. No unrelated code was changed to work around these restrictions. The broad test run completed with 37/42 tasks passing; its temporary SDK package-install failure passed separately after correcting cache locations.

Developed with AI assistance and independently reviewed by a separate AI agent. This is a draft for human review; the submitting contributor remains responsible for the change. No maintainer approval is claimed. External-contributor CI still requires the repository's normal team approval; this PR does not bypass that process.

@changeset-bot

changeset-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7cc1c66

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@browserbasehq/stagehand-extension Patch
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-python Patch
browse Patch
@browserbasehq/stagehand-examples Patch
@browserbasehq/stagehand-integrations-claude-cua-sdk Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/eve Patch
@browserbasehq/stagehand-integrations-gemini-cua-sdk Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-claude-agent-sdk Patch
@browserbasehq/stagehand-integrations-example-claude-code-facade Patch
@browserbasehq/stagehand-integrations-codex-sdk Patch
@browserbasehq/stagehand-integrations-example-codex-facade Patch
@browserbasehq/stagehand-integrations-cursor-sdk Patch
@browserbasehq/stagehand-integrations-example-cursor-facade Patch
@browserbasehq/stagehand-integrations-deepagents-sdk Patch
@browserbasehq/stagehand-integrations-eve-sdk Patch
@browserbasehq/stagehand-integrations-fx-sdk Patch
@browserbasehq/stagehand-integrations-mastra-sdk Patch
@browserbasehq/stagehand-integrations-example-mastra-facade Patch
@browserbasehq/stagehand-integrations-pi-sdk Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Oct 27, 2026
@raederhans
raederhans marked this pull request as ready for review October 28, 2026 14:12
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T14:12:25.794367Z 7cc1c66 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant