feat: add AbortSignal support to HttpClient for request cancellation#71
Open
OTimileyin wants to merge 1 commit into
Open
feat: add AbortSignal support to HttpClient for request cancellation#71OTimileyin wants to merge 1 commit into
OTimileyin wants to merge 1 commit into
Conversation
0acd0d1 to
a3753c4
Compare
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.
a3753c4 to
45d8c12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Changes Made:
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
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.