Skip to content

[fix]: rm legacy handlePossibleNavigation()#1761

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

[fix]: rm legacy handlePossibleNavigation()#1761
seanmcguire12 merged 1 commit intomainfrom
rm-handle-possible-nav

Conversation

@seanmcguire12
Copy link
Member

@seanmcguire12 seanmcguire12 commented Feb 26, 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

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
Copy link

changeset-bot bot commented Feb 26, 2026

🦋 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
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

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

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

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

Copy link
Contributor

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

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
@github-actions github-actions bot mentioned this pull request Feb 25, 2026
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