Skip to content

fix: respect opts.debug in installV3ShadowPiercer (fixes #1996)#2069

Open
kagura-agent wants to merge 1 commit intobrowserbase:mainfrom
kagura-agent:fix/respect-debug-option
Open

fix: respect opts.debug in installV3ShadowPiercer (fixes #1996)#2069
kagura-agent wants to merge 1 commit intobrowserbase:mainfrom
kagura-agent:fix/respect-debug-option

Conversation

@kagura-agent
Copy link
Copy Markdown

@kagura-agent kagura-agent commented Apr 30, 2026

Problem

installV3ShadowPiercer declares a debug?: boolean option in V3ShadowPatchOptions, but ignores it — DEBUG is hardcoded to true:

// hardcoded debug (remove later if desired)
const DEBUG = true;

This means console.info("[v3-piercer] attachShadow", ...) fires on every attachShadow call regardless of what the caller passes, and the debug field in V3ShadowPatchOptions is effectively dead API.

Fix

const DEBUG = opts.debug ?? false;

One-line change. Defaults to false (no debug noise) and respects the caller's choice when explicitly set.

Closes #1996.


Summary by cubic

Respect opts.debug in installV3ShadowPiercer by replacing the hardcoded DEBUG = true with const DEBUG = opts.debug ?? false. This removes noisy logs by default and lets callers enable debugging when needed (fixes #1996).

Written for commit 5c2f895. Summary will update on new commits. Review in cubic

…1996)

Replace hardcoded `const DEBUG = true` with `const DEBUG = opts.debug ?? false`
so callers can control debug logging via V3ShadowPatchOptions.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: 5c2f895

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

This PR includes changesets to release 4 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server-v3 Patch
@browserbasehq/stagehand-server-v4 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 Apr 30, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Caller as Calling Service/Script
    participant Piercer as installV3ShadowPiercer
    participant DOM as Element.prototype
    participant Console as Browser Console

    Note over Caller,DOM: Initialization Phase

    Caller->>Piercer: installV3ShadowPiercer(opts)
    Piercer->>Piercer: CHANGED: Evaluate DEBUG via opts.debug ?? false
    Piercer->>DOM: Patch attachShadow() logic
    DOM-->>Piercer: Done
    Piercer-->>Caller: Void

    Note over Caller,DOM: Runtime Execution Phase

    participant App as Web Application
    App->>DOM: element.attachShadow(init)
    
    alt DEBUG is true
        DOM->>Console: NEW: Log "[v3-piercer] attachShadow"
    else DEBUG is false
        Note over DOM,Console: No logging output
    end

    DOM->>DOM: Execute original attachShadow
    DOM->>DOM: Track shadow root in window.__v3ShadowRoots
    DOM-->>App: shadowRoot
Loading

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.

installV3ShadowPiercer ignores opts.debug — debug logging always enabled

1 participant