Skip to content

feat: forward ignoreDefaultArgs to chrome-launcher#2074

Open
CalebBarnes wants to merge 2 commits intobrowserbase:mainfrom
CalebBarnes:feat/forward-ignoreDefaultArgs-to-chrome-launcher
Open

feat: forward ignoreDefaultArgs to chrome-launcher#2074
CalebBarnes wants to merge 2 commits intobrowserbase:mainfrom
CalebBarnes:feat/forward-ignoreDefaultArgs-to-chrome-launcher

Conversation

@CalebBarnes
Copy link
Copy Markdown

@CalebBarnes CalebBarnes commented May 1, 2026

why

When running Stagehand locally, chrome-launcher adds its own set of default flags (e.g. --disable-extensions). There's currently no way for consumers to selectively remove these flags — localBrowserLaunchOptions.chromeFlags can only add flags, not remove chrome-launcher's built-in defaults.

This is needed when users want to run Chrome with extensions enabled, or need to remove other chrome-launcher defaults for their use case.

what changed

  • Added ignoreDefaultArgs option to LaunchLocalOptions in local.ts
  • Forwarded localBrowserLaunchOptions.ignoreDefaultArgs from v3.ts through to launchLocalChrome()
  • When true: drops all chrome-launcher defaults (only Stagehand's own flags and user-supplied chromeFlags are used)
  • When string[]: selectively removes only the listed flags from chrome-launcher defaults, keeping the rest

This mirrors the behavior of Playwright's ignoreDefaultArgs option.

test plan

  • Verified locally that setting ignoreDefaultArgs: ["--disable-extensions"] successfully removes the flag from the launched Chrome instance (confirmed via chrome://version/)
  • Verified that other chrome-launcher defaults are preserved when using the array form
  • Verified that ignoreDefaultArgs: true drops all chrome-launcher defaults

Summary by cubic

Adds ignoreDefaultArgs to local Chrome launch and forwards it to chrome-launcher so users can drop all or selected default flags while keeping Stagehand and user flags.

  • New Features
    • Added ignoreDefaultArgs to LaunchLocalOptions and wired it through V3 to launchLocalChrome(), mapping to chrome-launcher’s ignoreDefaultFlags.
    • true drops all chrome-launcher defaults; string[] removes only exact-matched defaults and re-adds the rest from Launcher.defaultFlags(), preserving Stagehand defaults and user chromeFlags.

Written for commit 1426616. Summary will update on new commits.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

🦋 Changeset detected

Latest commit: 1426616

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 Minor
@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

github-actions Bot commented May 1, 2026

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 May 1, 2026
@CalebBarnes CalebBarnes force-pushed the feat/forward-ignoreDefaultArgs-to-chrome-launcher branch from 9995492 to c0a459f Compare May 1, 2026 17:17
When localBrowserLaunchOptions.ignoreDefaultArgs is set, pass it through
launchLocalChrome to chrome-launcher's ignoreDefaultFlags option. This
allows consumers to selectively remove chrome-launcher's built-in default
flags (e.g. --disable-extensions) without losing Stagehand's own defaults.

- true: drops all chrome-launcher defaults
- string[]: drops only the listed flags, keeps the rest

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
@CalebBarnes CalebBarnes force-pushed the feat/forward-ignoreDefaultArgs-to-chrome-launcher branch from c0a459f to e899e32 Compare May 1, 2026 17:17
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 User as Consumer/SDK
    participant V3 as V3 Service
    participant Local as launchLocalChrome
    participant CL as chrome-launcher (Lib)
    participant OS as Chrome Process

    User->>V3: init(localBrowserLaunchOptions)
    Note right of User: Includes NEW: ignoreDefaultArgs
    
    V3->>Local: launchLocalChrome(opts)
    
    Local->>Local: Initialize chromeFlags (Stagehand defaults + User flags)

    alt ignoreDefaultArgs is boolean (true)
        Note over Local: User wants to drop ALL chrome-launcher defaults
        Local->>Local: Set ignoreDefaultFlags = true
    else ignoreDefaultArgs is string[]
        Note over Local: User wants to selectively remove defaults
        Local->>CL: CHANGED: Launcher.defaultFlags()
        CL-->>Local: Returns built-in flags (e.g. --disable-extensions)
        Local->>Local: Filter defaults based on ignoreDefaultArgs
        Local->>Local: Prepend kept defaults to chromeFlags
        Local->>Local: Set ignoreDefaultFlags = true
    end

    Local->>CL: launch({ ..., ignoreDefaultFlags, chromeFlags })
    
    CL->>OS: spawn chrome with final flag set
    OS-->>CL: Process started (PID/Port)
    
    CL-->>Local: LaunchedChrome object
    Local-->>V3: Connection details
    V3-->>User: Browser Instance Ready
Loading

Change flag filtering from substring (String.includes) to exact match,
consistent with Puppeteer/Playwright behavior. Add tests covering all
branches (true, false, string[], empty array), exact-match semantics,
Stagehand flag preservation, user flag merging, and duplicate behavior.

Update JSDoc and docs to reflect exact matching.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
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