Defjs
Core

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 | undefined

Aborts the call. An already aborted signal fails the call before transport.

onUploadProgress? HttpProgressFn | undefined

Observes HTTP upload progress.

onDownloadProgress? HttpProgressFn | undefined

Observes HTTP download progress.

beforeConnect? ((context: { attempt: number; signal: AbortSignal; }) => void | Promise<void>) | undefined

Runs before each WebSocket connect attempt for this call.

protocols? readonly string[] | undefined

WebSocket 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; } | undefined

WebSocket 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; } | undefined

WebSocket reconnect policy for this call. Replaces the client policy as a whole value.

Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao