fn

timeoutPlugin

v0.0.1

Composes 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>
PropertyTypeDescription
nameNamePlugin identifier
defaults?FetchOptionsDefault options contributed by the plugin — merged under user defaults
hooks?FetchHooksLifecycle hooks executed before any user per-request hooks
execute?FetchExecuteMiddlewareOnion-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 }) => voidInvoked 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.