RequestOptions
Flat per-call options. Each protocol reads the fields it understands and ignores the rest.
@defjs/core · Type
Signature
type RequestOptions = { signal?: AbortSignal; onUploadProgress?: HttpProgressFn; onDownloadProgress?: HttpProgressFn; beforeConnect?: ClientWebSocketOptions["beforeConnect"]; protocols?: readonly string[]; heartbeat?: ClientWebSocketOptions["heartbeat"]; reconnect?: ClientWebSocketOptions["reconnect"]; };
SSE reads only signal from request options. SSE reconnect comes from client configuration (withSSEReconnect), so client({ reconnect }) affects WebSocket only.
signal cancels HTTP, SSE, and WebSocket calls. onUploadProgress and onDownloadProgress apply to HTTP. beforeConnect, protocols, heartbeat, and reconnect apply to WebSocket and replace the client setting for that call as a whole value. There is no timeout or abort field. Pass AbortSignal.timeout(ms) as signal when a call needs a deadline.
Members
Prop
Type
signal? AbortSignal | undefinedAborts the call. An already aborted signal fails the call before transport.
onUploadProgress? HttpProgressFn | undefinedObserves HTTP upload progress.
onDownloadProgress? HttpProgressFn | undefinedObserves HTTP download progress.
beforeConnect? ((context: { attempt: number; signal: AbortSignal; }) => void | Promise<void>) | undefinedRuns before each WebSocket connect attempt for this call.
protocols? readonly string[] | undefinedWebSocket subprotocols for this call. Replaces the client list; it is not appended.
heartbeat? { intervalMs: number; isAck?: (message: unknown) => boolean; message?: <T = unknown>() => T | unknown; timeoutMs?: number; } | undefinedWebSocket heartbeat for this call. Replaces the client heartbeat as a whole value.
reconnect? { attempts?: number; delayMs?: number; factor?: number; jitter?: number; maxDelayMs?: number; shouldReconnect?: (context: { attempt: number; cause?: unknown; code?: number; reason?: string; wasClean?: boolean; }) => boolean; } | undefinedWebSocket reconnect policy for this call. Replaces the client policy as a whole value.