Skip to content

fix(core): pass local profile dir as Chrome flag - #2237

Open
luochen211 wants to merge 3 commits into
browserbase:mainfrom
luochen211:fix-local-user-data-dir-flag
Open

fix(core): pass local profile dir as Chrome flag#2237
luochen211 wants to merge 3 commits into
browserbase:mainfrom
luochen211:fix-local-user-data-dir-flag

Conversation

@luochen211

@luochen211 luochen211 commented Jun 11, 2026

Copy link
Copy Markdown

Summary

  • pass local browser userDataDir as a Chrome flag instead of a chrome-launcher option
  • preserve generated profile directories while avoiding WSL path conversion in launcher filesystem operations
  • add focused v4 regression coverage for launch arguments

Fixes #1503

Tests

  • pnpm --filter @browserbasehq/stagehand-extension build
  • pnpm --filter @browserbasehq/stagehand build
  • TypeScript SDK unit suite: 188/188 tests
  • oxfmt --check and oxlint on changed TypeScript files
  • git diff --check

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 289eeca

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

This PR includes changesets to release 5 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/stagehand-integrations-example-eve-facade Patch
@browserbasehq/stagehand-integrations-example-mastra-facade 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 Jun 11, 2026

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Test as Regression Test
    participant Launch as launchLocalChrome()
    participant Flags as ChromeFlags Builder
    participant Launcher as chrome-launcher

    Note over Test,Launcher: Launch flow

    Test->>Launch: call with userDataDir option
    Launch->>Flags: build chromeFlags array
    Flags->>Flags: append "--user-data-dir=<path>"
    Flags-->>Launch: chromeFlags list
    Launch->>Launcher: launch({ chromeFlags, ignoreDefaultFlags })
    Note over Launch,Launcher: userDataDir NOT passed to launcher
    Launcher->>Launcher: start Chrome with flags
    Launcher-->>Launch: browser instance

    Note over Test,Launcher: Assertion path

    Test->>Launch: getLaunchArgs() captures launcher options
    alt userDataDir option absent from launcher
        Test-->>Test: expect args.userDataDir to be undefined
    end
    alt chromeFlags contains user-data-dir
        Test-->>Test: expect "--user-data-dir=<path>" in flags
    end
Loading

Re-trigger cubic

@luochen211
luochen211 changed the base branch from main to v3 August 12, 2026 12:56
@luochen211

Copy link
Copy Markdown
Author

Retargeted this PR to v3: main moved to Stagehand v4 in #2671 and removed the v3 core launcher, while v3 is now the maintained base for this code. The PR is mergeable again and its diff remains limited to the original launcher fix, regression test, and patch changeset.\n\nValidation against current v3:\n- pnpm --dir packages/core run gen-version\n- pnpm --dir packages/core run build-dom-scripts\n- pnpm --dir packages/core run build:esm\n- targeted Vitest: 13/13 tests\n- pnpm --dir packages/core lint\n- git diff --check

@luochen211
luochen211 changed the base branch from v3 to main August 12, 2026 13:10
@luochen211

Copy link
Copy Markdown
Author

Follow-up after inspecting the v4 replacement: main now implements local launch in packages/sdk-ts/src/browser/localBrowser.ts, but still passed userDataDir through chrome-launcher, so the WSL2 path-conversion bug remained. I therefore kept this PR on main and replayed the fix on the v4 path rather than reviving deleted v3 files.\n\nCurrent diff against main is only:\n- v4 local browser launcher fix\n- focused unit regression test\n- TypeScript SDK patch changeset\n\nValidation:\n- focused tests: 2/2\n- TypeScript SDK unit suite: 188/188\n- extension + TypeScript SDK builds (including publint)\n- targeted oxfmt + oxlint\n- git diff --check

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.

[WSL2] userDataDir path converted to Windows format causes directory creation with literal backslashes on Linux

1 participant