signInWithPassword hangs indefinitely on correct credentials (but session IS created) #41329
Replies: 2 comments
|
I had same issue. This solved it: LogRocket intercepts network requests for session replay, and this is a known issue on iOS specifically. |
|
This behavior appears consistent with the auth initialization deadlock that was fixed in In affected versions, an This also explains the unusual symptom: authentication succeeds and the session is persisted, but I would first upgrade and pin the package: npm install @supabase/supabase-js@^2.110.1Then verify the installed version: npm ls @supabase/supabase-jsIt is also worth checking every supabase.auth.onAuthStateChange((event, session) => {
setTimeout(async () => {
if (event === 'SIGNED_IN') {
const { data, error } = await supabase.auth.getSession()
// Continue handling the authenticated session.
}
}, 0)
})The upstream fix is documented here: It was released in version 2.110.1: Since another reply mentioned LogRocket, I would also test once with session-replay/network interception disabled. If upgrading fixes the issue, the auth initialization deadlock was the likely cause; if disabling LogRocket fixes it instead, the interception layer is the more likely cause. Clearing all of |
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
I see there are some posts simular to this one from 2021 but i can seem to see anyhthing much more recent. If someone could point me in the right direction it would be appreaciated.
I'm encountering a very strange issue, and im sure its just something stupid and small that Im missing, with @supabase/supabase-js in my React application where the login promise hangs
indefinitely, but only when the credentials are correct.
The Environment:
The Behavior:
login credentials" error. This confirms my network and Supabase config are correct.
never rejects. It just hangs indefinitely.
Debugging & The "Smoking Gun":
To debug this, I wrapped the signIn call in a Promise.race with a 20-second timeout.
Here is the crazy part: When my timeout triggers, I check
supabase.auth.getSession(), and a valid session exists.This means Supabase is successfully logging the user in on the backend, and the client has the token, but the
signInWithPassword promise itself is failing to resolve, causing my UI to hang in a "Loading..." state.
Code Snippet:
// LOGIN FLOW
const loginPromise = supabase.auth.signInWithPassword({
email,
password,
});
// My Safety Timeout
const timeoutPromise = new Promise((_, reject) =>
setTimeout(async () => {
// CHECK IF WE ARE ACTUALLY LOGGED IN?
const { data } = await supabase.auth.getSession();
if (data.session) {
console.log("Login promise hung, BUT session exists!");
// This is what is happening. The session is there, but loginPromise never finished.
}
reject(new Error("Timeout"));
}, 20000)
);
await Promise.race([loginPromise, timeoutPromise]);
What I've Tried:
corrupted tokens are interfering.
Has anyone seen signInWithPassword fail to resolve despite successfully establishing a session? Is there a race
condition in the client-side state persistence?
Any help would be appreciated
All reactions