Skip to content

feat: add AbortSignal support to HttpClient for request cancellation#71

Open
OTimileyin wants to merge 1 commit into
Adamantine-guild:mainfrom
OTimileyin:feat/abortsignal-support
Open

feat: add AbortSignal support to HttpClient for request cancellation#71
OTimileyin wants to merge 1 commit into
Adamantine-guild:mainfrom
OTimileyin:feat/abortsignal-support

Conversation

@OTimileyin

Copy link
Copy Markdown

Closes #53

Description:

Adds signal?: AbortSignal to HttpRequestOptions so callers can cancel in-flight SDK requests. The external signal composes with the existing timeout controller via a per-attempt listener — whichever fires first wins. External aborts throw ABORTED; timeouts continue to throw TIMEOUT. Already-aborted signals short-circuit before any fetch work.

Semver impact: minor


Linked Issue:

Closes #53


Type of Change:

  • 🐛 Bug fix (patch)
  • ✨ New feature / method (minor)
  • 💥 Breaking change (major)
  • 📝 Documentation / TypeDoc update
  • 🔧 Chore / refactor
  • 🧪 Tests only

Changes Made:

  • src/errors/errorCodes.ts — added ABORTED = 'ABORTED' to GuildPassErrorCode
  • src/http/http.types.ts — added signal?: AbortSignal to HttpRequestOptions
  • src/http/httpClient.ts — early-abort guard; per-attempt listennal to internal AbortController; ABORTED vs TIMEOUT distinctionin catch block; listener cleanup on all code paths
  • tests/httpClient.test.ts — three new tests: already-aborted sietch, timeout-only (no signal)
  • docs/sdk-guide.md — added Cancellation section with usage example

Public API Changes:

// HttpRequestOptions — new optional field
signal?: AbortSignal;

// GuildPassErrorCode — new error code
ABORTED = 'ABORTED',


Test Evidence:

Test Files 9 passed (9)
Tests 103 passed (103)
Start at 04:16:32
Duration 3.88s (transform 731ms, setup 0ms, collect 1.76s, terepare 5.21s)


Build Evidence:

CJS ⚡️ Build success in 1511ms
ESM ⚡️ Build success in 1513ms
DTS ⚡️ Build success in 20807ms


  • I have read CONTRIBUTING.md
  • This PR is linked to an open issue
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test:run passes — all tests green
  • pnpm build succeeds — dist/ generated cleanly
  • All new public methods/types have TypeDoc comments
  • New behaviour is covered by at least one Vitest unit test
  • No new runtime dependencies added without prior maintainer approval
  • docs/ updated if public API changed
  • examples/ updated if new usage patterns were added
  • Backwards compatibility maintained (or breaking change clearly noted above)

Additional Notes:

AbortSignal.any() was considered but requires Node 20.3+; this Sals are composed manually viaaddEventListener/removeEventListener. AbortSignal.any() can replace this once Node 18 reaches EOL.

@OTimileyin OTimileyin force-pushed the feat/abortsignal-support branch from 0acd0d1 to a3753c4 Compare June 21, 2026 03:33
Adds an optional signal field to HttpRequestOptions that composes with
the existing timeout controller. External aborts throw ABORTED; timeouts
continue to throw TIMEOUT. Already-aborted signals short-circuit before
any fetch work. Closes Adamantine-guild#53.
@OTimileyin OTimileyin force-pushed the feat/abortsignal-support branch from a3753c4 to 45d8c12 Compare June 21, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add AbortSignal support to HTTP requests

1 participant