Skip to content

fix(extension): prune descendant frameOwnerPage entries on frame detach and page close - #3403

Open
FelixFangX wants to merge 1 commit into
browserbase:mainfrom
FelixFangX:feature/prune-descendant-frame-owners-792a
Open

FelixFangX wants to merge 1 commit into
browserbase:mainfrom
FelixFangX:feature/prune-descendant-frame-owners-792a

Conversation

@FelixFangX

@FelixFangX FelixFangX commented Nov 5, 2026 •

Copy link
Copy Markdown

Summary

Closing pages with nested frames left stale frameOwnerPage entries: Page.frameDetached deleted only the detached frame id and did not prune descendants still mapped to the same owner.

This PR prunes the detached frame and every descendant still owned by the same page on detach (unless reason === \"swap\"), and applies the same prune on page close before clearing remaining entries for the closed page.

Fixes #3240

Test plan

  • OOPIF context fixture failed on unmodified upstream main (NESTED_FRAME / same-origin grandchildren stayed in the map) and passes with this change
  • Extension unit tests otherwise green (extension-build checks need a built dist/ not produced by this change)

Summary by cubic

Fixes stale frameOwnerPage entries left behind when frames detach or pages close, so a reused browser context no longer retains ownership of closed pages.

  • Prunes the detached frame and all descendants still owned by the same page on frame detach, unless the reason is swap.
  • Applies the same prune on page close and keeps frames owned by other pages intact.

Written for commit 5549fd2. Summary will update on new commits.

View guided diff

@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5549fd2

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

This PR includes changesets to release 23 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-python Patch
@browserbasehq/stagehand-extension 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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-05T03:55:26.853378Z
We couldn’t complete this review. Comment @codex review to try again.
44a6fc7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Nov 5, 2026

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 Nov 5, 2026
…ch and page close

Page.frameDetached deleted only the detached frame id, so nested frames
kept BrowserContext.frameOwnerPage entries after the subtree was removed.
Prune the detached frame and descendants still mapped to the same owner
when the detach reason is not swap, and when the page closes.

Fixes browserbase#3240

Co-authored-by: Felix Fang <FelixFangX@users.noreply.github.com>
@FelixFangX
FelixFangX force-pushed the feature/prune-descendant-frame-owners-792a branch from 44a6fc7 to 5549fd2 Compare November 6, 2026 02:47

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.

Closing pages with nested frames leaves stale frame ownership references

2 participants