豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

fix: Improve navigate_page_history error messages#321

Merged
OrKoN merged 9 commits intoChromeDevTools:mainfrom
mithun50:main
Oct 13, 2025
Merged

fix: Improve navigate_page_history error messages#321
OrKoN merged 9 commits intoChromeDevTools:mainfrom
mithun50:main

Conversation

@mithun50
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

mithun50 commented Oct 9, 2025

Fixes: #259

@Lightning00Blade Lightning00Blade self-requested a review October 9, 2025 18:47
Comment thread src/tools/pages.ts Outdated
Comment thread src/tools/pages.ts
Per puppeteer/puppeteer#14160, null return from goBack/goForward
indicates successful navigation without network request, not failure.
Puppeteer throws error when no history exists.

Simplified to append error.message as suggested by @OrKoN.
@OrKoN OrKoN merged commit 0624029 into ChromeDevTools:main Oct 13, 2025
17 checks passed
OrKoN pushed a commit that referenced this pull request Oct 13, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.8.1](chrome-devtools-mcp-v0.8.0...chrome-devtools-mcp-v0.8.1)
(2025-10-13)


### Bug Fixes

* add an option value to the snapshot
([#362](#362))
([207137e](207137e))
* improve navigate_page_history error messages
([#321](#321))
([0624029](0624029))
* return the default dialog value correctly
([#366](#366))
([f08f808](f08f808))
* update puppeteer to 24.24.1
([#370](#370))
([477eef4](477eef4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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