Repository navigation
Conversation
…dialog The page-evaluation path of evaluate_script passes handleDialog (default 'accept') to waitForEventsAfterAction, so a dialog opened by the script is auto-accepted. But unlike the sibling service-worker path (which calls clearDialog() when result.dialogHandled) and navigate_page, the page path never clears McpPage's stored dialog reference. The persistent 'dialog' listener on McpPage records every dialog in #dialog, so after the auto-accepted dialog is gone, #dialog still points at it. evaluate_script and many other tools are blockedByDialog: true, so the next such tool hits throwIfDialogOpen() and fails with a misleading 'A dialog is open' error, wedging the session until handle_dialog is called or the page is navigated/closed. Clear the dialog state on the page path too, mirroring the worker path. Adds a regression test that fails on the previous behavior. Fixes ChromeDevTools#2424
Lightning00Blade
requested changes
Jul 27, 2026
Collaborator
There was a problem hiding this comment.
Thank you for the PR,
I recently added a change to Puppeteer, it will allows to track the dialog state regardless where it got handled.
puppeteer/puppeteer#15225
Then we can handle this inside throwIfDialogOpen, which would mean we don't have to track each individual place this could happen.
Because of that I will close this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2424
Problem
After
evaluate_scriptruns a script that opens a JS dialog (alert/confirm/prompt), every subsequent dialog-blocked tool fails with a misleadingA dialog is open (...)error — even though the dialog was already auto-handled and is gone. The session stays wedged untilhandle_dialogis called or the page is navigated/closed.McpPagestores every dialog in#dialogvia a persistent'dialog'listener. The page-evaluation path ofevaluate_scriptpasseshandleDialog(default'accept') so the dialog is auto-accepted, but — unlike the sibling service-worker path (script.ts:100-102) andnavigate_page(pages.ts:274-278) — it never clears#dialog. Sinceevaluate_scriptand most tools areblockedByDialog: true, the next one throws onthrowIfDialogOpen().Fix
On the page path, clear the dialog state when a dialog was handled, mirroring the worker path:
Testing
clears the dialog state after auto-handling a dialog: evaluates() => { confirm('hello'); return 'done'; }and assertsgetDialog()isundefinedandthrowIfDialogOpen()doesn't throw. Fails onmain(getDialog()returns the already-accepted dialog) and passes with this change.npm run test tests/tools/script.test.ts— all tests pass.