From ee3b894910597ca61f6747adfcd80d9f0899cbcf Mon Sep 17 00:00:00 2001 From: lynxeco Date: Tue, 12 Aug 2025 00:17:37 -0700 Subject: [PATCH] fix: resolve stale closure bug in fetchToken callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fetchToken callback in ConvexBetterAuthProvider had incorrect dependencies, causing it to capture stale authClient references. This prevented Convex JWT token fetching from working correctly when authClient prop changed or plugins were dynamically loaded. - Updated dependency array from [client] to [authClient, logVerbose] - Ensures callback updates when authClient changes (fixing dynamic plugin loading) - Fixes silent authentication failures in mobile/native apps using Better Auth with Convex 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/react/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/react/client.tsx b/src/react/client.tsx index 963c308..847a8ba 100644 --- a/src/react/client.tsx +++ b/src/react/client.tsx @@ -110,7 +110,7 @@ export function AuthProvider({ }; return fetchWithRetry(); - }, [client]); + }, [authClient, logVerbose]); const fetchAccessToken = useCallback( async ({ forceRefreshToken }: { forceRefreshToken: boolean }) => {