Summary
Allow callers to cancel in-flight SDK requests using an external AbortSignal. This improves integration with browser UI lifecycles, server request handlers, and applications that need user-driven cancellation.
Current Behaviour
HttpClient creates its own AbortController for timeout handling, but HttpRequestOptions does not accept an external signal. Consumers cannot cancel requests when components unmount, route handlers are aborted, or a newer request supersedes an older one.
Expected Behaviour
SDK request options should accept an optional AbortSignal and abort the underlying fetch when either the timeout or the external signal fires.
Suggested Implementation
Add signal?: AbortSignal to HttpRequestOptions. Update HttpClient.request to compose timeout cancellation with external cancellation. Ensure timeout errors and user-initiated aborts can be distinguished where possible.
Files or Areas Likely Affected
src/http/http.types.ts
src/http/httpClient.ts
src/errors/errorCodes.ts
tests/httpClient.test.ts
docs/sdk-guide.md
Acceptance Criteria
Additional Notes
This should complement the existing timeout implementation rather than replacing it.
Summary
Allow callers to cancel in-flight SDK requests using an external
AbortSignal. This improves integration with browser UI lifecycles, server request handlers, and applications that need user-driven cancellation.Current Behaviour
HttpClientcreates its ownAbortControllerfor timeout handling, butHttpRequestOptionsdoes not accept an externalsignal. Consumers cannot cancel requests when components unmount, route handlers are aborted, or a newer request supersedes an older one.Expected Behaviour
SDK request options should accept an optional
AbortSignaland abort the underlyingfetchwhen either the timeout or the external signal fires.Suggested Implementation
Add
signal?: AbortSignaltoHttpRequestOptions. UpdateHttpClient.requestto compose timeout cancellation with external cancellation. Ensure timeout errors and user-initiated aborts can be distinguished where possible.Files or Areas Likely Affected
src/http/http.types.tssrc/http/httpClient.tssrc/errors/errorCodes.tstests/httpClient.test.tsdocs/sdk-guide.mdAcceptance Criteria
HttpRequestOptionsaccepts an optionalAbortSignalfetchAdditional Notes
This should complement the existing timeout implementation rather than replacing it.