Repository navigation
fix(navigate): return beforeunload dialogs from browser_navigate_back - #277
Conversation
browser_navigate_back awaited page.goBack() directly, so a beforeunload (or load-time) dialog blocked the tool until the navigation timeout. Race the history navigation against modal states the same way browser_navigate already does, and report the dialog immediately. Mirrors upstream microsoft/playwright#43252. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NYnf61YoZEXnVaQJ52XjUT
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efb5f63819
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed all three reviewed concerns in 9a61750; replied to and resolved each thread after verification. The stale-modal replay defect is reproduced with a controlled Validation:
Lazy-clean triage:
GitHub CI is running on the new commit. |
Upstream change
fix(mcp): race browser_navigate_back and forward against modal states(commit microsoft/playwright@6e5419a)Upstream now runs
page.goBack()/page.goForward()inside_raceAgainstModalStates. Before that, abeforeunloaddialog on the current page blocked the tool until the navigation timeout ran out, and the dialog never came back as a modal state.Why it matters here
browser_navigate_backinsrc/tools/navigate.tsawaitedtab.goBack()directly, so it had the same bug.browser_navigatealready races against modal states (Tab.navigate(..., { returnOnDialog: true })), but going back did not. I reproduced it locally: the new test hangs past 5 s onmain. (This repo has nobrowser_navigate_forward, so only going back needs the fix.)Fix
Tab.goBackReturningOnDialog()races the history navigation against modal states, the same waynavigate()does. If a dialog wins the race, a later navigation failure is kept as a console message instead of becoming an unhandled rejection.browser_navigate_backuses it and leaves out thepage.goBack()code line when it returns a dialog, the same asbrowser_navigate.auditKeyboard's internaltab.goBack()is unchanged.Tests
tests/navigation-dialogs.test.ts: a page with abeforeunloadhandler, then a click, thenbrowser_navigate_back. The tool returns the"beforeunload"dialog right away, andbrowser_handle_dialogthen finishes the navigation. It fails onmainand passes with this fix.tools-navigateunit-test mock.npm run lintandnpm run knipare clean. The fullvitestrun fails the same 30 tests with and without this change. They are in history-downloads, extension-protocol, cdp-frame-tree and browser-upgrade-controls, and fail because the sandbox has no full Chromium 1243 binary. None of them are caused by this change.Other upstream MCP commits reviewed (no action)
browser_routeheader fixes): this repo has nobrowser_routetool.--redact-url-params): this is a new opt-in feature, not a fix. I'm leaving it for a separate decision.browser_navigatehere never added a scheme to bare URLs, so nothing regresses.🤖 Generated with Claude Code
https://claude.ai/code/session_01NYnf61YoZEXnVaQJ52XjUT
Generated by Claude Code
Summary by CodeRabbit
The PR appears safe to merge, with a non-blocking request to test later errors from back navigation.
Findings
Fix with agent prompt
Summary
This PR lets
browser_navigate_backreturn an open dialog instead of waiting for the navigation timeout.Diagram
Reviews (1) · Last reviewed commit: "fix(navigate): return beforeunload dialo..." · Reviewed by Greptile