feat(mcp): make heartbeat ping timeout configurable#41391
Open
yury-s wants to merge 1 commit into
Open
Conversation
Add PLAYWRIGHT_MCP_PING_TIMEOUT_MS to override the default 5s heartbeat ping timeout. A non-positive value disables the heartbeat entirely, so clients/proxies that don't answer server-initiated pings are no longer reaped. Fixes microsoft/playwright-mcp#982 Fixes microsoft/playwright-mcp#1293 Fixes microsoft/playwright-mcp#1140 Fixes microsoft/playwright-mcp#1307
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a configurable MCP HTTP heartbeat ping timeout via PLAYWRIGHT_MCP_PING_TIMEOUT_MS, including the ability to disable the heartbeat with a non-positive value, and covers the behavior with HTTP transport tests.
Changes:
- Add env-controlled ping timeout (default 5s) and allow disabling heartbeat when
<= 0. - Add HTTP transport tests to verify session reaping on unanswered pings and no reaping when heartbeat is disabled.
- Extend the test server launcher helper to allow passing custom environment variables.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/mcp/http.spec.ts | Adds heartbeat-related HTTP transport tests and allows injecting env vars into the MCP server process. |
| packages/playwright-core/src/tools/utils/mcp/server.ts | Introduces configurable heartbeat ping timeout and supports disabling heartbeat. |
Comment on lines
+156
to
+164
| const pingTimeout = (): number => { | ||
| const value = process.env.PLAYWRIGHT_MCP_PING_TIMEOUT_MS; | ||
| if (value === undefined) | ||
| return defaultPingTimeout; | ||
| const parsed = Number(value); | ||
| if (!Number.isFinite(parsed)) | ||
| return defaultPingTimeout; | ||
| return parsed; | ||
| }; |
Contributor
Test results for "MCP"7380 passed, 1122 skipped Merge workflow run. |
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
PLAYWRIGHT_MCP_PING_TIMEOUT_MSto override the default 5s heartbeat ping timeout.Fixes microsoft/playwright-mcp#982
Fixes microsoft/playwright-mcp#1293
Fixes microsoft/playwright-mcp#1307