Repository navigation
Conversation
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.
Summary
When the document that owns a pending WebMCP invocation is reloaded or navigated by anything other than the tool itself,
POST /webmcp/invokewaits out the fulltimeout_sec(up to 120s) before returningoutcome_unknown, even though no result can ever arrive.Chromium only answers a pending invocation across a navigation when the tool started that navigation (
WebMCPHandler::DidFinishNavigationchecksGetScriptToolInvocationId()): cross-origin gets an immediateError, same-origin gets a result from the new document around itsDOMContentLoaded. A reload or navigation from Playwright, the user, or unrelated page script never producesWebMCP.toolResponded.webmcpclientdropped the frame's tools on a document change but kept the invocation waiting.Change
EventDocumentChanged).Page.frameStoppedLoadingon the same session and frame), give it a 500ms grace and then fail the invocation with the existingErrOutcomeUnknown(still returnsinvocation_id).Waiting for the replacement load rather than a fixed delay after commit keeps tool-initiated navigations working: their result can arrive seconds after commit on slow pages, but always before the load finishes. No API or error-code change.
Tests
reloadWithoutResultin the fake CDP server replays the event sequence observed from Chromium for an external reload (frameStartedLoading→frameNavigated→frameStoppedLoading, notoolResponded).TestInvocationFailsFastWhenToolDocumentReloadsWithoutResultwaited the full 10s before this change and returns in about 1s after.frameStoppedLoadingbefore the late result, covering the grace window.go vet ./...clean;go test -racepasses for all non-e2e packages exceptlib/devtoolsproxyTestUpstreamManagerDetectsChromiumAndRestart, which fails the same way onmainin my environment (temp dir cleanup with local Chromium) and doesn't depend on this package.webmcpclient.Manageragainst a production Chromium 155 browser over CDP (20s timeout):Page.navigate/ page-script reloadoutcome_unknownoutcome_unknownCompletedwith outputCompletedwith outputErrorErrorNot included
tool_page_unloaded) and adispatchedfield need OpenAPI, API, and SDK changes; left for a follow-up.WebMCP.invokeTooldispatch and its response isn't tracked and still waits for the timeout.Reviewed with sol-loop: 1 round with openai-codex/gpt-6.1-sol on extra-high reasoning. Sol verdict: approved.