API reference › @evolu/common › Http › FetchConsume
type FetchConsume<T, E> = (response: Response) => Awaitable<Result<T, E>>;
Defined in: packages/common/src/Http.ts:154
Consumes a native Response before fetch settles.
The callback runs inside the fetch Task, while the request signal is still alive. Return a Result error for expected domain failures. Throwing or rejecting with a non-abort error is a defect, like any other Task body.
Consumers take values, not dependencies; close over anything they need. A consumer that needs its own timeout, retries, or child Tasks has outgrown being a consumer: fetch the body with a mode and compose Tasks on the plain value, or write a Task that owns the whole request.
Consumers do not have to normalize abort. fetch rethrows Evolu
AbortError, normalizes host abort errors after the Run aborts, and
treats an Err returned after abort as abort control flow — so a consumer's
try/catch around a body read cannot accidentally turn an abort into a
domain error. An Ok returned after abort is kept; only errors are presumed to
be abort in disguise.
The Response and anything derived from its live body, such as a reader, must not escape the consumer. Consume to plain values before returning.