Repository navigation
Conversation
…esolves CDP can deliver WebMCP.toolResponded before the response to the WebMCP.invokeTool command that started it. The invocation record was only created after the command resolved, so the early event was dropped and waitForWebMCPInvocationResult() hung, or timed out. Hold responses for unknown invocation IDs on the session's response state while an invokeTool command is in flight, settle the new record from the held response when the command resolves, and clear the buffer once nothing is pending or the session is torn down so it stays bounded. Fixes browserbase#2724
🦋 Changeset detectedLatest commit: 9940360 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
This branch has not been deployed
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.
why
Fixes #2724.
WebMCP.toolRespondedcan arrive before theWebMCP.invokeToolcommand response reveals its invocation ID. The listener currently drops that event because the invocation has not been registered yet, leavingwaitForWebMCPInvocationResult()pending indefinitely or until its timeout.what changed
invokeToolcommand is in flight on that session.Related: #2727 and #2887 address the same race condition. This implementation reuses the existing per-session response state and pending-command count, clearing unclaimed responses when the last pending command finishes or the session is torn down.
test plan
toolRespondedfrom inside the fakeinvokeToolhandler, which is the ordering from the issue: early Completed, Canceled and Error responses; duplicates before and after registration; concurrent commands resolving in reverse order; isolation between sessions; stale responses not claimed by a later invocation; the failed-command path; retention; detach and dispose mid-command.changeset statuspass.--checkpass, and theextensionassetsandextensionpackGo tests pass.