Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-local-profiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Pass local browser profile directories as Chrome flags instead of chrome-launcher options.
2 changes: 1 addition & 1 deletion packages/core/lib/v3/launch/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export async function launchLocalChrome(
opts.ignoreHTTPSErrors ? "--ignore-certificate-errors" : undefined,
opts.proxy?.server ? `--proxy-server=${opts.proxy.server}` : undefined,
opts.proxy?.bypass ? `--proxy-bypass-list=${opts.proxy.bypass}` : undefined,
opts.userDataDir ? `--user-data-dir=${opts.userDataDir}` : undefined,
...(opts.args ?? []),
].filter((f): f is string => typeof f === "string");

Expand All @@ -76,7 +77,6 @@ export async function launchLocalChrome(
chromePath: opts.executablePath,
chromeFlags,
port: opts.port,
userDataDir: opts.userDataDir,
handleSIGINT: opts.handleSIGINT,
ignoreDefaultFlags,
connectionPollInterval,
Expand Down
19 changes: 16 additions & 3 deletions packages/core/tests/unit/launch-local-ignore-default-args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ afterEach(() => {
vi.unstubAllGlobals();
});

async function getLaunchArgs(
opts: Record<string, unknown>,
): Promise<{ chromeFlags: string[]; ignoreDefaultFlags: boolean }> {
async function getLaunchArgs(opts: Record<string, unknown>): Promise<{
chromeFlags: string[];
ignoreDefaultFlags: boolean;
userDataDir?: string;
}> {
const { launchLocalChrome } = await import("../../lib/v3/launch/local.js");
await launchLocalChrome(opts);
return launchMock.mock.calls[0][0];
Expand Down Expand Up @@ -214,4 +216,15 @@ describe("launchLocalChrome ignoreDefaultArgs", () => {
expect(args.chromeFlags).toContain("--renderer-process-limit=6");
expect(args.chromeFlags).toContain("--remote-allow-origins=*");
});

it("passes userDataDir as a Chrome flag instead of a chrome-launcher option", async () => {
const args = await getLaunchArgs({
userDataDir: "/home/user/project/chrome-profile",
});

expect(args.userDataDir).toBeUndefined();
expect(args.chromeFlags).toContain(
"--user-data-dir=/home/user/project/chrome-profile",
);
});
});
Loading