HeadlinesBriefing favicon HeadlinesBriefing.com

TypeScript Effectful HTTP Client, Retries & Cancellation

DEV Community •
×

Part four of the Brass TS series demonstrates how modeling HTTP as an effect transforms typical networking concerns into first‑class runtime capabilities. The brass-http client does not wrap fetch; instead it builds a pure description of work that is interpreted by a scheduler backed by fibers and structured concurrency. Because execution is deferred, retries become scheduled policies rather than ad‑hoc loops, and cancellation propagates structurally across the entire request lifecycle, eliminating best‑effort aborts.

The article shows concrete TypeScript examples, including configuring retry policies, converting effects to promises with toPromise, and accessing raw wire responses that remain retryable and cancelable. It also highlights that requests are immutable data values, enabling composable pipelines and future streaming APIs. By treating HTTP as an effect, developers gain predictable retry behavior, reliable cancellation, easier testing, and natural composition, addressing long‑standing pain points of Promise‑based HTTP handling in JavaScript ecosystems.