Skip to main content
Every SDK method accepts an optional final argument, RequestOptions, that controls cancellation, per-call timeouts, and one-off headers. The same object works for regular requests and for Server-Sent Events streams.

RequestOptions

signal

An AbortSignal that cancels the request. If the signal aborts before the response arrives, the SDK throws a FigraniumError with code: "REQUEST_ABORTED".
For streams, aborting the signal ends iteration cleanly:

timeoutMs

Overrides the client-wide default timeout for this call. The client default is 30_000 ms; you can set a shorter or longer bound per request.
Streams have no default timeout. Set timeoutMs on a stream only when you want a terminal deadline; the stream aborts and throws when it hits that limit.

headers

Extra headers merged over the client’s default headers for this call. Useful for request correlation IDs, feature flags, or overriding a default value once.

Combining options

Pass all three together when needed:
Some methods extend RequestOptions with extra fields (for example tasks.save accepts createVersion). Those flags travel in the same options object.

Cancellation semantics

  • Aborting an AbortSignal before the response starts causes the fetch to reject; the SDK translates that into FigraniumError { code: "REQUEST_ABORTED" }.
  • The client-wide timeout, and any per-call timeoutMs, is implemented as an internal AbortController with a DOMException of type TimeoutError. It surfaces as the same REQUEST_ABORTED error.
  • Streams stop iterating when the signal aborts. Any pending reader is cancelled and the connection is closed.
Use signal for user-initiated cancellation and timeoutMs for hard deadlines. Combining both gives you precise control over request lifetimes.
See Errors for the shape of the thrown error.