fn
timeoutPlugin
v0.0.1Composes an AbortSignal.timeout(ms) with any caller-supplied signal
when options.timeout is set.
Implemented as an execute middleware (inner to retry) so every retry attempt
gets a brand-new timeout signal — a single timeout no longer poisons all
subsequent attempts. The timeout therefore applies per attempt, not to the whole
retry sequence.
Auto-registered by createFetch; no-op when timeout is unset.
Signature
ts
export function timeoutPlugin(){ ... }Returns
FetchPlugin<"timeout", unknown, unknown>| Property | Type | Description |
|---|---|---|
name | Name | Plugin identifier |
defaults? | FetchOptions | Default options contributed by the plugin — merged under user defaults |
hooks? | FetchHooks | Lifecycle hooks executed before any user per-request hooks |
execute? | FetchExecuteMiddleware | Onion-style middleware wrapping the fetch attempt + response parse.
Plugins compose in registration order; calling next() invokes the next
middleware or ultimately the core executor. May call next() multiple
times (e.g. to implement retries). |
setup? | (context: { readonly defaults: FetchOptions }) => void | Invoked once per createFetch, after all plugin defaults are merged |
__types? | { options: OptionsExt; context: ContextExt } | Phantom marker for type-only option/context extensions — never present at runtime.
Populated via dummy field in definePlugin generics. |