Skip to content

fix(extension): keep cookie attributes when clearCookies re-adds cookies - #3212

Open
nancy6547 wants to merge 1 commit into
browserbase:mainfrom
nancy6547:fix/clear-cookies-keep-attributes
Open

nancy6547 wants to merge 1 commit into
browserbase:mainfrom
nancy6547:fix/clear-cookies-keep-attributes

Conversation

@nancy6547

@nancy6547 nancy6547 commented Oct 16, 2026 •

Copy link
Copy Markdown

clearCookies() with a filter clears every cookie and re-adds the ones that don’t match. It rebuilt them from the public Cookie shape, which has no partition key, priority, or source scheme/port, and it turns an unset SameSite into Lax. So calling clearCookies({ name: "x" }) changed cookies it was supposed to leave alone. A partitioned (CHIPS) cookie came back unpartitioned, and a High priority cookie came back as Medium.

I reproduced this in Chrome with Storage.setCookies / Storage.getCookies: the partition key was present before the call and missing after.

This re-adds the kept cookies from what Storage.getCookies returned (cdpCookieToParam in cookies.ts). addCookies() is unchanged.

Tests: packages/extension/tests/understudy-context-cookies.test.ts (mocked CDP connection). The first test fails without the change.


Summary by cubic

Fixes clearCookies() with a filter stripping attributes from the cookies it keeps. The method cleared every cookie and re-added the non-matching ones from the public Cookie shape, which drops the partition key, priority, source scheme and port, and turns an unset SameSite into Lax — so a partitioned (CHIPS) cookie came back unpartitioned and a High priority cookie came back as Medium.

Kept cookies are now re-added from the full Storage.getCookies data via a new cdpCookieToParam mapping; addCookies() is unchanged. Adds tests with a mocked CDP connection covering partition key, priority, SameSite, expiry, and the no-match case.

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

View guided diff

clearCookies() with a filter clears every cookie and re-adds the ones that
don't match. It rebuilt them from the public Cookie shape, which drops the
partition key, priority, source scheme and port, and turns an unset
SameSite into Lax. A partitioned (CHIPS) cookie that should have been kept
came back unpartitioned. Re-add the cookies from what Storage.getCookies
returned instead.
@changeset-bot

changeset-bot Bot commented Oct 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e05f6bb

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

This PR includes changesets to release 22 packages
Name Type
@browserbasehq/stagehand-extension Patch
@browserbasehq/stagehand 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 16, 2026

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