fix(mcp): wait for client event stream before server->client requests#41559
Merged
pavelfeldman merged 1 commit intoJul 1, 2026
Merged
Conversation
Over the Streamable HTTP transport, server->client requests (e.g. listRoots during initialization) can only be delivered once the client has opened its standalone GET SSE event stream. Thread a transportInitialized promise through connect()/createServer() and await it before issuing listRoots. It resolves when the client issues the GET event-stream request, or after a 5s fallback timeout so clients that never open the stream are not blocked.
yury-s
approved these changes
Jun 30, 2026
| const capabilities = server.getClientCapabilities(); | ||
| let clientRoots: Root[] = []; | ||
| if (capabilities?.roots) { | ||
| await transportInitialized; |
Member
There was a problem hiding this comment.
should it just resolve to false in this case, so that we don't need to send listRoots at all?
Member
Author
There was a problem hiding this comment.
I'm trying to be extra conservative here: wait for up to 5 seconds, relative to what was happening before the change, to not affect customers.
Contributor
Test results for "MCP"7461 passed, 1132 skipped Merge workflow run. |
yury-s
added a commit
to microsoft/playwright-mcp
that referenced
this pull request
Jul 9, 2026
## What's New ### New Tools - **`browser_find`** — Search the accessibility snapshot of the current page for text or a regular expression. Returns matching snapshot nodes with a few lines of surrounding context (like search snippets), which is cheaper than capturing the whole snapshot when you only need to locate an element and its ref ([#41605](microsoft/playwright#41605), [#41654](microsoft/playwright#41654)) ### Tool Improvements - **Less verbose snapshots** — Accessibility snapshots are distilled to reduce noise and token usage ([#41604](microsoft/playwright#41604)) - **Mobile & device emulation** — New `--mobile` flag and `--device` option to emulate mobile devices from the CLI ([#41657](microsoft/playwright#41657)) - **Navigation status** — `browser_navigate` now surfaces non-2xx navigation status codes ([#41589](microsoft/playwright#41589)) ## Bug Fixes - Enable the chromium sandbox for the default browser ([#41652](microsoft/playwright#41652)) - Close the isolated HTTP client context on disconnect ([#41560](microsoft/playwright#41560)) - Wait for the client event stream before sending server→client requests ([#41559](microsoft/playwright#41559))
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
listRootsduring init) can only be delivered after the client opens its standalone GET SSE event stream.transportInitializedpromise throughconnect()/createServer()and await it before issuinglistRoots.