fix: handle createClient rejection so isLoading resolves#97
Conversation
Without a .catch() on the createClient promise chain, any rejection (network failure, DNS error, hung custom domain) leaves isLoading stuck at true forever, rendering apps unable to show their unauthenticated state.
Greptile SummaryFixes an edge case where
Confidence Score: 4/5The core fix is correct and resolves a real stuck-loading bug; the two concerns are about error handler scope and observability rather than correctness of the happy path. The change achieves its goal — src/provider.tsx — specifically the Important Files Changed
|
| .catch(() => { | ||
| setState((prev) => ({ ...prev, isLoading: false })); | ||
| }); |
There was a problem hiding this comment.
Silent error swallowing makes failures invisible
The .catch() handler discards the rejection entirely — no logging, no exposed error state. When createClient fails due to a misconfigured apiHostname, DNS error, or network timeout, the app silently moves to the unauthenticated state with zero diagnostic signal. In production this makes the root cause nearly impossible to identify without additional instrumentation.
Summary
.catch()handler to thecreateClient(...).then(...)promise chain inAuthKitProvidercreateClientrejection (network failure, DNS error, hung custom domain, misconfiguredapiHostname) leavesisLoadingstuck attrueforeverSurfaced by VectorShift after an environment promotion where a custom auth domain wasn't bootstrapped — their app showed a permanent loading state because
isLoadingnever resolved.Related: workos/authkit-js#117 (post-sleep lock timeout), workos/authkit-js (fetch timeout PR)
Test plan
npm run buildpasses (tsup — CJS, ESM, DTS)createClientrejects (e.g., invalidclientId, unreachableapiHostname),isLoadingtransitions tofalseand the app renders unauthenticated UIisLoading: falsewith a valid user