Skip to content

[fix]: rm legacy handlePossibleNavigation() - #1761

Merged
seanmcguire12 merged 1 commit into
mainfrom
rm-handle-possible-nav
Feb 26, 2026
Merged

seanmcguire12 merged 1 commit into
mainfrom
rm-handle-possible-nav

Conversation

@seanmcguire12

@seanmcguire12 seanmcguire12 commented Feb 26, 2026 •

Copy link
Copy Markdown
Member

why

  • this function was from legacy stagehand which only operated on one page
  • presently, it was only being used to produce a log which:
    • at best, misinformed users on whether the page had actually navigated, and,
    • at worst, resulted in a noisy error log
    • the error log would happen if clickElement() triggered page closure. this means that the frame.evaluate() to get the URL would attempt .evaluate() on a frame that no longer existed

what changed

  • removed handlePossibleNavigation()

test plan

  • existing tests are fine here

Summary by cubic

Removed the legacy handlePossibleNavigation() that tried to detect navigation by URL and produced misleading logs. This also prevents errors when clicks close the page and evaluate runs on a non-existent frame, reducing log noise.

Written for commit 1d2c3d6. Summary will update on new commits. Review in cubic

@changeset-bot

changeset-bot Bot commented Feb 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1d2c3d6

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

This PR includes changesets to release 3 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server 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

@greptile-apps

greptile-apps Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Removes the legacy handlePossibleNavigation() function that was producing misleading navigation logs and error logs when clicks triggered page closure.

  • Deleted the handlePossibleNavigation() function (37 lines) that attempted to detect page navigation by comparing URLs before and after actions
  • Removed the call to handlePossibleNavigation() from performUnderstudyMethod() after action execution
  • The function was problematic because frame evaluation would fail when clicking elements that close pages (e.g., close buttons), causing noisy error logs
  • Clean removal with appropriate changeset documentation

Confidence Score: 5/5

  • This PR is safe to merge - it removes problematic legacy code without introducing any new functionality or complexity
  • This is a straightforward bug fix that removes code causing error logs, with no new functionality to introduce bugs. The change is minimal (removing a function and its call site), well-documented in the changeset, and the author confirms existing tests pass
  • No files require special attention

Important Files Changed

Filename Overview
.changeset/some-parrots-wave.md Adds standard changeset documentation for the patch
packages/core/lib/v3/handlers/handlerUtils/actHandlerUtils.ts Removes legacy handlePossibleNavigation() function and its call site, eliminating error logs when clicks trigger page closure

Last reviewed commit: 1d2c3d6

@greptile-apps greptile-apps 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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@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 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Handler as Action Handler
    participant Frame as Browser Frame
    participant Logger as v3Logger

    Note over Handler, Frame: performUnderstudyMethod()

    Handler->>Frame: Execute Browser Action (e.g. click)
    
    alt Action triggers Page/Frame Closure
        Frame-->>Handler: Success (Frame detached)
        Note over Handler: CHANGED: No longer calls Frame.url() <br/> avoiding 'Frame detached' error logs
    else Happy Path
        Frame-->>Handler: Success (Frame exists)
    end

    opt Execution Error
        Handler->>Logger: Log error & stack trace
    end

    Handler-->>Handler: Return result/error status
Loading

@seanmcguire12
seanmcguire12 merged commit 611f43a into main Feb 26, 2026
160 checks passed
miguelg719 pushed a commit that referenced this pull request Mar 18, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @browserbasehq/[email protected]

### Minor Changes

- [#1816](#1816)
[`687d54a`](687d54a)
Thanks [@shrey150](https://github.com/shrey150)! - Add `--context-id`
and `--persist` flags to `browse open` for loading and persisting
Browserbase Contexts across sessions

- [#1793](#1793)
[`e38c13b`](e38c13b)
Thanks [@shrey150](https://github.com/shrey150)! - Initial release of
browse CLI - browser automation for AI agents

### Patch Changes

- [#1806](#1806)
[`f8c7738`](f8c7738)
Thanks [@shrey150](https://github.com/shrey150)! - Fix `browse env`
showing stale mode after `browse env remote`

- Updated dependencies
\[[`505e8c6`](505e8c6),
[`2f43ffa`](2f43ffa),
[`63ee247`](63ee247),
[`7dc35f5`](7dc35f5),
[`335cf47`](335cf47),
[`6ba0a1d`](6ba0a1d),
[`4ff3bb8`](4ff3bb8),
[`c27054b`](c27054b),
[`2abf5b9`](2abf5b9),
[`7817fcc`](7817fcc),
[`7390508`](7390508),
[`611f43a`](611f43a),
[`521a10e`](521a10e),
[`2402a3c`](2402a3c)]:
    -   @browserbasehq/[email protected]

## @browserbasehq/[email protected]

### Minor Changes

- [#1779](#1779)
[`2f43ffa`](2f43ffa)
Thanks [@shrey150](https://github.com/shrey150)! - feat: add
`cdpHeaders` option to `localBrowserLaunchOptions` for passing custom
HTTP headers when connecting to an existing browser via CDP URL

- [#1834](#1834)
[`63ee247`](63ee247)
Thanks [@tkattkat](https://github.com/tkattkat)! - Update stagehand
agents search tool

- [#1774](#1774)
[`521a10e`](521a10e)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add new
page.setExtraHTTPHeaders() method

### Patch Changes

- [#1759](#1759)
[`505e8c6`](505e8c6)
Thanks [@shrey150](https://github.com/shrey150)! - Add bedrock to the
provider enum in model configuration schemas and regenerate OpenAPI
spec.

- [#1814](#1814)
[`7dc35f5`](7dc35f5)
Thanks [@tkattkat](https://github.com/tkattkat)! - Change usage of
openai provider in agent to default to store:false

- [#1846](#1846)
[`335cf47`](335cf47)
Thanks [@aq17](https://github.com/aq17)! - Fix streaming finished event
being silently dropped. The final SSE event containing the result
payload (success status, message, actions, usage, and messages) was
previously discarded instead of being yielded to the caller.

- [#1764](#1764)
[`6ba0a1d`](6ba0a1d)
Thanks [@shrey150](https://github.com/shrey150)! - Expose `headers` in
`GoogleVertexProviderSettings` so model configs can pass custom provider
headers (for example `X-Goog-Priority`) without TypeScript errors.

- [#1847](#1847)
[`4ff3bb8`](4ff3bb8)
Thanks [@miguelg719](https://github.com/miguelg719)! - Enable FlowLogger
on BROWSERBASE_FLOW_LOGS=1

- [#1752](#1752)
[`c27054b`](c27054b)
Thanks [@derekmeegan](https://github.com/derekmeegan)! - fix: pause
Browserbase agents while captcha solving is active and improve CUA
recovery after the solve completes

- [#1800](#1800)
[`2abf5b9`](2abf5b9)
Thanks [@shrey150](https://github.com/shrey150)! - Make projectId
optional for Browserbase sessions — only BROWSERBASE_API_KEY is required

- [#1766](#1766)
[`7817fcc`](7817fcc)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add configurable
timeout to tools in agent

- [#1749](#1749)
[`7390508`](7390508)
Thanks [@pirate](https://github.com/pirate)! - When connecting to a
browser session that has zero open tabs, Stagehand now automatically
creates an initial `about:blank` tab so the connection can continue.

- [#1761](#1761)
[`611f43a`](611f43a)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue
where handlePossibleNavigation was producing unnecessary error logs on
clicks that trigger page close

- [#1817](#1817)
[`2402a3c`](2402a3c)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add support for
passing custom headers in clientOptions

## @browserbasehq/[email protected]

### Patch Changes

- Updated dependencies
\[[`505e8c6`](505e8c6),
[`2f43ffa`](2f43ffa),
[`63ee247`](63ee247),
[`7dc35f5`](7dc35f5),
[`335cf47`](335cf47),
[`6ba0a1d`](6ba0a1d),
[`4ff3bb8`](4ff3bb8),
[`c27054b`](c27054b),
[`2abf5b9`](2abf5b9),
[`7817fcc`](7817fcc),
[`7390508`](7390508),
[`611f43a`](611f43a),
[`521a10e`](521a10e),
[`2402a3c`](2402a3c)]:
    -   @browserbasehq/[email protected]

## @browserbasehq/[email protected]

### Patch Changes

- [#1759](#1759)
[`505e8c6`](505e8c6)
Thanks [@shrey150](https://github.com/shrey150)! - Add bedrock to the
provider enum in model configuration schemas and regenerate OpenAPI
spec.

- Updated dependencies
\[[`505e8c6`](505e8c6),
[`2f43ffa`](2f43ffa),
[`63ee247`](63ee247),
[`7dc35f5`](7dc35f5),
[`335cf47`](335cf47),
[`6ba0a1d`](6ba0a1d),
[`4ff3bb8`](4ff3bb8),
[`c27054b`](c27054b),
[`2abf5b9`](2abf5b9),
[`7817fcc`](7817fcc),
[`7390508`](7390508),
[`611f43a`](611f43a),
[`521a10e`](521a10e),
[`2402a3c`](2402a3c)]:
    -   @browserbasehq/[email protected]

## @browserbasehq/[email protected]

### Patch Changes

- Updated dependencies
\[[`505e8c6`](505e8c6),
[`2f43ffa`](2f43ffa),
[`63ee247`](63ee247),
[`7dc35f5`](7dc35f5),
[`335cf47`](335cf47),
[`6ba0a1d`](6ba0a1d),
[`4ff3bb8`](4ff3bb8),
[`c27054b`](c27054b),
[`2abf5b9`](2abf5b9),
[`7817fcc`](7817fcc),
[`7390508`](7390508),
[`611f43a`](611f43a),
[`521a10e`](521a10e),
[`2402a3c`](2402a3c)]:
    -   @browserbasehq/[email protected]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
felipeofdev-ai pushed a commit to felipeofdev-ai/stagehand that referenced this pull request Aug 4, 2026
# why
- this function was from legacy stagehand which only operated on one
page
- presently, it was only being used to produce a log which:
- at best, misinformed users on whether the page had actually navigated,
and,
  - at worst, resulted in a noisy error log
- the error log would happen if `clickElement()` triggered page closure.
this means that the frame.evaluate() to get the URL would attempt
`.evaluate()` on a frame that no longer existed
# what changed
- removed `handlePossibleNavigation()`
# test plan
- existing tests are fine here

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Removed the legacy handlePossibleNavigation() that tried to detect
navigation by URL and produced misleading logs. This also prevents
errors when clicks close the page and evaluate runs on a non-existent
frame, reducing log noise.

<sup>Written for commit 1d2c3d6.
Summary will update on new commits. <a
href="https://cubic.dev/pr/browserbase/stagehand/pull/1761">Review in
cubic</a></sup>

<!-- End of auto-generated description by cubic. -->
felipeofdev-ai pushed a commit to felipeofdev-ai/stagehand that referenced this pull request Aug 4, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @browserbasehq/[email protected]

### Minor Changes

- [browserbase#1816](browserbase#1816)
[`687d54a`](browserbase@687d54a)
Thanks [@shrey150](https://github.com/shrey150)! - Add `--context-id`
and `--persist` flags to `browse open` for loading and persisting
Browserbase Contexts across sessions

- [browserbase#1793](browserbase#1793)
[`e38c13b`](browserbase@e38c13b)
Thanks [@shrey150](https://github.com/shrey150)! - Initial release of
browse CLI - browser automation for AI agents

### Patch Changes

- [browserbase#1806](browserbase#1806)
[`f8c7738`](browserbase@f8c7738)
Thanks [@shrey150](https://github.com/shrey150)! - Fix `browse env`
showing stale mode after `browse env remote`

- Updated dependencies
\[[`505e8c6`](browserbase@505e8c6),
[`2f43ffa`](browserbase@2f43ffa),
[`63ee247`](browserbase@63ee247),
[`7dc35f5`](browserbase@7dc35f5),
[`335cf47`](browserbase@335cf47),
[`6ba0a1d`](browserbase@6ba0a1d),
[`4ff3bb8`](browserbase@4ff3bb8),
[`c27054b`](browserbase@c27054b),
[`2abf5b9`](browserbase@2abf5b9),
[`7817fcc`](browserbase@7817fcc),
[`7390508`](browserbase@7390508),
[`611f43a`](browserbase@611f43a),
[`521a10e`](browserbase@521a10e),
[`2402a3c`](browserbase@2402a3c)]:
    -   @browserbasehq/[email protected]

## @browserbasehq/[email protected]

### Minor Changes

- [browserbase#1779](browserbase#1779)
[`2f43ffa`](browserbase@2f43ffa)
Thanks [@shrey150](https://github.com/shrey150)! - feat: add
`cdpHeaders` option to `localBrowserLaunchOptions` for passing custom
HTTP headers when connecting to an existing browser via CDP URL

- [browserbase#1834](browserbase#1834)
[`63ee247`](browserbase@63ee247)
Thanks [@tkattkat](https://github.com/tkattkat)! - Update stagehand
agents search tool

- [browserbase#1774](browserbase#1774)
[`521a10e`](browserbase@521a10e)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add new
page.setExtraHTTPHeaders() method

### Patch Changes

- [browserbase#1759](browserbase#1759)
[`505e8c6`](browserbase@505e8c6)
Thanks [@shrey150](https://github.com/shrey150)! - Add bedrock to the
provider enum in model configuration schemas and regenerate OpenAPI
spec.

- [browserbase#1814](browserbase#1814)
[`7dc35f5`](browserbase@7dc35f5)
Thanks [@tkattkat](https://github.com/tkattkat)! - Change usage of
openai provider in agent to default to store:false

- [browserbase#1846](browserbase#1846)
[`335cf47`](browserbase@335cf47)
Thanks [@aq17](https://github.com/aq17)! - Fix streaming finished event
being silently dropped. The final SSE event containing the result
payload (success status, message, actions, usage, and messages) was
previously discarded instead of being yielded to the caller.

- [browserbase#1764](browserbase#1764)
[`6ba0a1d`](browserbase@6ba0a1d)
Thanks [@shrey150](https://github.com/shrey150)! - Expose `headers` in
`GoogleVertexProviderSettings` so model configs can pass custom provider
headers (for example `X-Goog-Priority`) without TypeScript errors.

- [browserbase#1847](browserbase#1847)
[`4ff3bb8`](browserbase@4ff3bb8)
Thanks [@miguelg719](https://github.com/miguelg719)! - Enable FlowLogger
on BROWSERBASE_FLOW_LOGS=1

- [browserbase#1752](browserbase#1752)
[`c27054b`](browserbase@c27054b)
Thanks [@derekmeegan](https://github.com/derekmeegan)! - fix: pause
Browserbase agents while captcha solving is active and improve CUA
recovery after the solve completes

- [browserbase#1800](browserbase#1800)
[`2abf5b9`](browserbase@2abf5b9)
Thanks [@shrey150](https://github.com/shrey150)! - Make projectId
optional for Browserbase sessions — only BROWSERBASE_API_KEY is required

- [browserbase#1766](browserbase#1766)
[`7817fcc`](browserbase@7817fcc)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add configurable
timeout to tools in agent

- [browserbase#1749](browserbase#1749)
[`7390508`](browserbase@7390508)
Thanks [@pirate](https://github.com/pirate)! - When connecting to a
browser session that has zero open tabs, Stagehand now automatically
creates an initial `about:blank` tab so the connection can continue.

- [browserbase#1761](browserbase#1761)
[`611f43a`](browserbase@611f43a)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue
where handlePossibleNavigation was producing unnecessary error logs on
clicks that trigger page close

- [browserbase#1817](browserbase#1817)
[`2402a3c`](browserbase@2402a3c)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add support for
passing custom headers in clientOptions

## @browserbasehq/[email protected]

### Patch Changes

- Updated dependencies
\[[`505e8c6`](browserbase@505e8c6),
[`2f43ffa`](browserbase@2f43ffa),
[`63ee247`](browserbase@63ee247),
[`7dc35f5`](browserbase@7dc35f5),
[`335cf47`](browserbase@335cf47),
[`6ba0a1d`](browserbase@6ba0a1d),
[`4ff3bb8`](browserbase@4ff3bb8),
[`c27054b`](browserbase@c27054b),
[`2abf5b9`](browserbase@2abf5b9),
[`7817fcc`](browserbase@7817fcc),
[`7390508`](browserbase@7390508),
[`611f43a`](browserbase@611f43a),
[`521a10e`](browserbase@521a10e),
[`2402a3c`](browserbase@2402a3c)]:
    -   @browserbasehq/[email protected]

## @browserbasehq/[email protected]

### Patch Changes

- [browserbase#1759](browserbase#1759)
[`505e8c6`](browserbase@505e8c6)
Thanks [@shrey150](https://github.com/shrey150)! - Add bedrock to the
provider enum in model configuration schemas and regenerate OpenAPI
spec.

- Updated dependencies
\[[`505e8c6`](browserbase@505e8c6),
[`2f43ffa`](browserbase@2f43ffa),
[`63ee247`](browserbase@63ee247),
[`7dc35f5`](browserbase@7dc35f5),
[`335cf47`](browserbase@335cf47),
[`6ba0a1d`](browserbase@6ba0a1d),
[`4ff3bb8`](browserbase@4ff3bb8),
[`c27054b`](browserbase@c27054b),
[`2abf5b9`](browserbase@2abf5b9),
[`7817fcc`](browserbase@7817fcc),
[`7390508`](browserbase@7390508),
[`611f43a`](browserbase@611f43a),
[`521a10e`](browserbase@521a10e),
[`2402a3c`](browserbase@2402a3c)]:
    -   @browserbasehq/[email protected]

## @browserbasehq/[email protected]

### Patch Changes

- Updated dependencies
\[[`505e8c6`](browserbase@505e8c6),
[`2f43ffa`](browserbase@2f43ffa),
[`63ee247`](browserbase@63ee247),
[`7dc35f5`](browserbase@7dc35f5),
[`335cf47`](browserbase@335cf47),
[`6ba0a1d`](browserbase@6ba0a1d),
[`4ff3bb8`](browserbase@4ff3bb8),
[`c27054b`](browserbase@c27054b),
[`2abf5b9`](browserbase@2abf5b9),
[`7817fcc`](browserbase@7817fcc),
[`7390508`](browserbase@7390508),
[`611f43a`](browserbase@611f43a),
[`521a10e`](browserbase@521a10e),
[`2402a3c`](browserbase@2402a3c)]:
    -   @browserbasehq/[email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants