feat: add internal timeout and AbortSignal composition to api client#378
Closed
Devadakene wants to merge 1 commit into
Closed
feat: add internal timeout and AbortSignal composition to api client#378Devadakene wants to merge 1 commit into
Devadakene wants to merge 1 commit into
Conversation
Contributor
|
Thanks — this is the same api.ts timeout/AbortSignal composition commit that already landed via #380. Zero net diff after merging main in, so closing as already covered. |
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 #156
PR Description
Type of Change
Description
This pull request adds an internal timeout and robust
AbortSignalcomposition to the HTTP client functionsapiRequestandapiTextRequestin api.ts to prevent requests from hanging indefinitely on stalled backends.Key Changes
ApiRequestInitwhich extends standardRequestInitwith an optionaltimeout?: numberproperty.globalDefaultTimeoutMsset to10s/10000ms) along with a helper functionsetDefaultTimeout.composeSignalswhich combines the internal timeout-basedAbortControllerwith any caller-suppliedAbortSignal.ApiRequestErrorwith status code408and the error code set to"TIMEOUT".AbortErrorDOMExceptions, ensuringisAbortErrorreturnstruefor intentional cancellations.Verification Results
All tests passed successfully:
RUN v2.1.9 C:/Users/HP/drips/work/AnchorNet-Frontend Coverage enabled with v8 ✓ src/lib/api.test.ts (26 tests) 110ms Test Files 1 passed (1) Tests 26 passed (26) % Coverage report from v8 ----------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ----------------|---------|----------|---------|---------|------------------- All files | 100 | 100 | 100 | 100 | api.ts | 100 | 100 | 100 | 100 | ----------------|---------|----------|---------|---------|-------------------