Timeouts
Enforce total and per-attempt timeouts with a real AbortSignal.
Add timeout when a slow or hung response shouldn't be allowed to block the
caller indefinitely — the stitch bounds the call with a real AbortSignal, so a
breached deadline actually aborts the in-flight request rather than leaking it.
Example
import { } from 'stitchapi';
const = ({
: 'https://api.example.com',
: '/report',
: { : '10s', : '3s' },
});Each call to report() gives every attempt at most 3 seconds and the whole call
at most 10 seconds; whichever fires first aborts the request.
Options
total bounds the entire call across every retry; perAttempt bounds each
individual attempt on its own. Both accept either a number of milliseconds
(3000) or a duration string ('3s'), so total: '10s' and total: 10000 are
equivalent.
The deadline is backed by a real AbortSignal: when it elapses the stitch
aborts the underlying request — the connection is actually cancelled, not just
ignored — and the call fails with a timeout.
With retry, the two timeouts compose: each try
is gated by perAttempt, while total caps the sum of all tries plus their
backoff waits, so a long enough total is what lets a slow attempt be retried at
all.
A breached deadline aborts the call and surfaces as a timeout error. See STITCH_TIMEOUT for how it reads and how to fix it.
See Reference → Config types for the full
TimeoutOptions shape.