Repository navigation
refactor(mcp): share execution timeout handling across tools - #3338
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 042499c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
1 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 1 minor None could be anchored to changed lines; they are listed below. Findings outside the changed lines1 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
|
E2E Test Results✅ All tests passed • 406 passed • 1 skipped • 1308s
Tests ran across 4 shards in parallel. |
Deep ReviewRefactor consolidating five hand-rolled MCP timeout patterns into a shared 🟡 P2 -- recommended
🔵 P3 nitpicks (3)
Reviewers (7): correctness, adversarial, reliability, kieran-typescript, testing, maintainability, previous-comments. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
Summary
MCP tools each hand-rolled their own wall-clock timeout: an
AbortController, one or twosetTimeouts, aPromise.race, and either a marker error (DESCRIBE_METRIC_TIMEOUT,LIST_METRICS_TIMEOUT) or a sentinel symbol to detect the timeout. They now sharerunWithTimeoutinmcp/utils/timeout.ts, and the 30s ClickHouse cap comes from one constant instead of literal30s scattered across tools. Each tool keeps its own budget.Resolves HDX-5606. Follow-up to #3260 (comment).
runWithTimeout(work, { timeoutMs, graceMs }):workattimeoutMs, and stops waitinggraceMslater — work that returns partial results after the abort keeps them (whatdescribe_sourceneeds)clickstack_describe_sourceclickstack_describe_metricclickstack_list_metricsquery_tileswithDeadline(per tile, shared batch deadline)list_sourcesmetric-name previewMCP_CLICKHOUSE_SETTINGS,MCP_REQUEST_TIMEOUT(30s + 2s), and themax_execution_timeindenoise,runEventPatterns, andeventDeltasnow derive from the shared constants.Not converted:
scanKindsForPage(its deadline finalizes a page rather than cancelling work) and the per-query ClickHouse caps (14s/28s/3s/2.5s), which are tuned per tool.Behavior change:
describe_source,describe_metric,list_metrics, and thelist_sourcespreview now abort their signal on every exit, not only on timeout.withDeadlinealready did this.Test plan
timeout.test.tscovers success, abort at the deadline, partial results in the grace window, the backstop, and rejections before/after the abortdescribeSourceTimeout,withDeadline, andlistMetrics*unit tests pass unchangedsources,queryTiles, anddeltasToolintegration suites pass