Skip to content

Conversation

mithun50
Copy link
Contributor

@mithun50 mithun50 commented Oct 9, 2025

Problem

The navigate_page_history tool previously suppressed all
navigation errors with a generic message: "Unable to
navigate {back|forward} in currently selected page." This
provided no context about why the navigation failed, making
it difficult for users to understand whether:

  • No page exists in the history
  • A timeout occurred
  • Some other error happened

Solution

Enhanced error handling to provide specific, actionable
feedback:

  1. Check navigation result: Capture the return value
    from goBack()/goForward() to detect when navigation is
    impossible
  2. No history detection: When result is null, return:
    "Cannot navigate back, no previous page in history."
  3. Timeout errors: Show duration: "Navigation back timed
    out after 30000ms."
  4. Other errors: Include actual error message instead of
    generic text

Changes

  • Modified navigate_page_history handler in
    src/tools/pages.ts
  • Added result checking for null (no history available)
  • Enhanced error messages with specific context
  • Improved debugging experience for users

Testing

  • Verify "no previous page" message when navigating back on
    first page
  • Verify "no next page" message when navigating forward at
    end of history
  • Confirm timeout errors show duration
  • Ensure other errors display actual error messages

Check navigation result and provide specific feedback:
- Detect when no previous/next page exists in history
- Show timeout errors with duration details
- Include actual error messages instead of generic text
@mithun50 mithun50 changed the title Improve navigate_page_history error messages fix: Improve navigate_page_history error messages Oct 9, 2025
@mithun50
Copy link
Contributor Author

mithun50 commented Oct 9, 2025

Fixes: #259

@Lightning00Blade Lightning00Blade self-requested a review October 9, 2025 18:47
result = await page.goForward(options);
}

// If result is null, navigation wasn't possible (no history)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not correct. Successful navigations could result in a null result if the navigation has no network request. We fixed Puppeteer in puppeteer/puppeteer#14160 to throw an error when there is no history. So the null result, should be treated as a successful navigation.

}
} catch {
response.appendResponseLine(
`Unable to navigate ${request.params.navigate} in currently selected page.`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be sufficient to add the error.message to this message and revert other changes

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