fix: add fetch timeout to prevent indefinite hangs#118
Open
nicknisi wants to merge 1 commit into
Open
Conversation
Adds AbortSignal.timeout(30s) to the HTTP client's POST method so a misconfigured or unreachable custom auth domain times out instead of blocking initialization forever.
cmatheson
approved these changes
May 15, 2026
|
|
||
| it("does not hang when the API is unreachable and the fetch times out", async () => { | ||
| const originalFetch = global.fetch; | ||
| const timeoutError = new DOMException( |
Collaborator
There was a problem hiding this comment.
kind of think it would feel better if we wrapped this error (instead of passing the DOMException straight through), but i don't feel too strongly about it if you disagree.
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.
Summary
AbortSignal.timeout(30_000)to the HTTP client's#postmethodfetch()to block indefinitely —initialize()never resolves and the React provider'sisLoadingstaystrueforeverSurfaced by VectorShift after promoting their staging environment to production —
identity.vectorshift.aiwasn't routing correctly andfetchhung with no timeout.Related: #117 (post-sleep lock timeout), workos/authkit-react (createClient rejection handling PR)
Test plan
npm test)createClientresolves (not hangs) when fetch rejects with aTimeoutErrornpm run buildpassesapiHostnamepoints to an unreachable domain, initialization times out after ~30s instead of hanging forever