[P2] `QueryClient` distributed-tracing observability in `BaseDataService`
Los mantenedores suelen responder en 1 día
@MajorLift ya está trabajando en esto.
Desde el 21/9/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 50/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- typescript
- Área
- observability
Línea de trabajo
Comienza con packages/base-data-service/src/BaseDataService.ts y sigue cómo se crea y utiliza su QueryClient interno. Evalúa las opciones del getter y del constructor-hook, y verifica después que la conexión posterior de queryCache.subscribe pueda observar el ciclo de vida de la caché y de las solicitudes sin cambiar la superficie de UI, el comportamiento de OmitKeyof, el contrato del messenger ni la semántica de proxy queryFn.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Parent Epic: None (standalone)
File: packages/base-data-service/src/BaseDataService.ts
Size: S | Hours: 2–4
Problem
Option A's proxy model (TanStack Query QueryClient in the background process, proxy queryFn in the UI) intentionally hides the cache, dedupe, retry, fetch, and sync chain from UI-perceived latency tracing. The distributed-tracing wrappers in metamask-extension#39891 give us the call boundaries (useQuery → submitRequestToBackground → messenger → BaseDataService action → response). Inside the opaque region, every interesting decision is invisible:
- Cache hit vs. miss. Most data service calls don't make a network request. Auto-instrumented fetch spans see zero. The query looks "slow" with no attribution.
- In-flight dedupe. N concurrent observers collapse to one fetch. The fetch span doesn't know N.
- Cockatiel retry sequences. A single logical "fetch this" can produce 0, 1, or many HTTP requests. Auto-spans see them as unrelated. Backoff intervals are invisible.
- Circuit breaker state. When open, no fetch happens. The query fails or returns cached data with no auto-span at all.
- Cache sync to UI.
setData → cacheUpdated event → Port.postMessage → UI hydrateis the post-fetch synchronization cost. None of it surfaces as a span. - Trigger attribution. Poll interval, user invalidation, observer subscribe, and WebSocket invalidation are all identical from the network's view.
Three Option A tradeoffs documented in decisions#131 currently depend on observability that doesn't exist:
- Per-screen
staleTime. Validating that the service-side workarounds hold in production requires distinguishing fetches from cache serves. refetchOnMount/refetchOnWindowFocuscollapse. Measuring whether concurrent queries amplify messenger volume or are absorbed by backgroundstaleTime.- Split-process staleness indirection. Correlating UI proxy calls with background fetches.
Without this visibility, the tradeoffs are theoretical. With it, they're verifiable.
Solution
Add a sanctioned extension point to BaseDataService that exposes the internal QueryClient for read-only observability subscriptions. Two variants; preference is maintainer's call:
- Public getter.
get queryClient(): QueryClient - Constructor callback.
onCreate?: (qc: QueryClient) => void
Either is ~3 lines in core. Downstream clients attach their own instrumentation externally (e.g. qc.getQueryCache().subscribe(emitSpan) plus Cockatiel onRetry / onBreak handlers in extension's Sentry init, ~50 lines). The full span chain becomes stitchable end-to-end:
useQuery → submitRequestToBackground (span) → messenger (span) →
[BaseDataService.fetchQuery — cache miss, observerAdded → fetching →
Cockatiel attempt 1 → fetch (auto, child of rpc.handler) → 503 →
backoff 200ms → fetch (auto) → 200 → setData → success] →
cacheUpdated → port → UI hydrate
Acceptance Criteria
-
BaseDataServiceexposes either a publicqueryClientgetter or anonCreateconstructor hook (maintainer's choice). - Downstream
queryCache.subscribe(...)wiring composes cleanly from a client-side Sentry init file. A prototype in the extension repo demonstrates the full stack trace fromuseQuerythrough retry through success. - No new UI-facing surface.
- No change to
OmitKeyoftype erasure. - No change to messenger contract.
- No change to proxy
queryFnsemantics.
Labels
area-data-service, area-observability
Dependencies
Related: #8530, #8531 (orthogonal — same epic scope but different surface; not blocking).
Depends on: none.
Dependents: none.
- Lenguaje dominante
- TypeScript
- Estrellas
- 424
- Forks
- 311
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 446
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MetaMask/core
-
EIP-1898 object selectors fail before downstream RPC in eth-json-rpc-middleware 26.0.0Posiblemente ocupada @debojyoti10CC la tomó hace 5 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
CI: "Validate changelog diffs" job fails on every fork-sourced pull requestPosiblemente ocupada @Roxen-AS la tomó hace 37 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
platform-api-docs: `scan` strategy misses ESM-only packages, which ship `.d.ts` rather than `.d.cts`Posiblemente ocupada @gaohan1994 la tomó hace 38 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[utils] Replace the `uuid` dependency with `crypto.randomUUID()`Posiblemente ocupada @avantikonde la tomó hace 51 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
MetaMask/core#10210 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
[utils] `toWei` accepts fractional wei and returns wrong valuesPosiblemente ocupada @Roxen-AS la tomó hace 37 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
Todos los issues de MetaMask/core
Issues similares
-
Flaky test: selecting a portion just after inserting it can also match its Change and Delete buttonsAbiertoready-for-agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
linagora/dcs-onlyoffice#172 ·
-
bug follow-up
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
nightly-tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
BlackBeltTechnology/pi-agent-dashboard#1226 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
danielmiessler/LifeOS#3028 ·
Los mantenedores suelen responder en 5 días
-
execute_sql cannot create a SQLite trigger or a PostgreSQL BEGIN ATOMIC function: the statement is cut at the semicolons inside its bodyPosiblemente ocupada @goranai la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día