From 7860556dce7d201355221a3f31fca707cb23c7bd Mon Sep 17 00:00:00 2001 From: Max Bader Date: Thu, 16 Jul 2026 09:23:21 -0500 Subject: [PATCH] Handle getUser rejection in onAuthStateChange If the initial auth.getUser() call rejects, fall back to notifying the listener with SIGNED_OUT / null instead of leaving an unhandled promise rejection. Co-Authored-By: Claude Opus 4.8 --- src/client.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client.ts b/src/client.ts index 9a1ac5d..5c6fbd4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -384,9 +384,12 @@ export function createBoolClient(config: BoolClientConfig): BoolClient { }, onAuthStateChange(callback: AuthChangeListener) { authListeners.add(callback); - auth.getUser().then(({ data }) => - callback(data.user ? "SIGNED_IN" : "SIGNED_OUT", data.user), - ); + auth + .getUser() + .then(({ data }) => + callback(data.user ? "SIGNED_IN" : "SIGNED_OUT", data.user), + ) + .catch(() => callback("SIGNED_OUT", null)); return { data: { subscription: {