Skip to content

instrumentShapeFetch

instrumentShapeFetch(baseFetch?): typeof fetch

Defined in: packages/client/src/debug.ts:72

Wrap a fetch so every ShapeStream request (the Electric read-path long-poll/catch-up) emits a start line (shape/table, offset, live — derived from the request URL params) and a completion line (status, ms, and whether the response is up-to-date). Passthrough when instrumentation is off: the early return runs before any URL parsing, so the off-path pays nothing per request beyond this closure itself.

Inject it as a ShapeStream fetchClient; pass the stream’s existing fetchClient (if any) as the base so the instrumentation composes rather than replaces.

typeof fetch = fetch

typeof fetch