Skip to content

feat(mcp): make heartbeat ping timeout configurable#41391

Open
yury-s wants to merge 1 commit into
microsoft:mainfrom
yury-s:feat-mcp-ping-timeout
Open

feat(mcp): make heartbeat ping timeout configurable#41391
yury-s wants to merge 1 commit into
microsoft:mainfrom
yury-s:feat-mcp-ping-timeout

Conversation

@yury-s

@yury-s yury-s commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary

  • 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#1307

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
};
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7380 passed, 1122 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants